Skip to content

Commit

Permalink
Merge pull request #961 from twomiao/master
Browse files Browse the repository at this point in the history
Updated Swoole TcpConnection
  • Loading branch information
walkor authored Oct 9, 2023
2 parents 06d3a6d + d9e2be0 commit 74bce26
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/Connection/TcpConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Workerman\Protocols\Http\Request;
use Workerman\Protocols\ProtocolInterface;
use Workerman\Worker;

use function ceil;
use function count;
use function fclose;
Expand All @@ -45,6 +46,7 @@
use function strrpos;
use function substr;
use function var_export;

use const PHP_INT_MAX;
use const STREAM_CRYPTO_METHOD_SSLv23_CLIENT;
use const STREAM_CRYPTO_METHOD_SSLv23_SERVER;
Expand Down Expand Up @@ -352,7 +354,7 @@ public function __construct(EventInterface $eventLoop, $socket, string $remoteAd
$this->maxPackageSize = self::$defaultMaxPackageSize;
$this->remoteAddress = $remoteAddress;
static::$connections[$this->id] = $this;
$this->context = new stdClass;
$this->context = new stdClass();
}

/**
Expand Down Expand Up @@ -388,7 +390,11 @@ public function send(mixed $sendBuffer, bool $raw = false)
if (false === $raw && $this->protocol !== null) {
/** @var ProtocolInterface $parser */
$parser = $this->protocol;
$sendBuffer = $parser::encode($sendBuffer, $this);
try {
$sendBuffer = $parser::encode($sendBuffer, $this);
} catch(\Throwable $e) {
$this->error($e);
}
if ($sendBuffer === '') {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Events/Swoole.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,12 @@ public function onSignal(int $signal, callable $func): void
}

/**
* Please see https://wiki.swoole.com/#/process/process?id=signal
* {@inheritdoc}
*/
public function offSignal(int $signal): bool
{
return Process::signal($signal, function () {
});
return Process::signal($signal, null);
}

/**
Expand Down

0 comments on commit 74bce26

Please sign in to comment.