diff --git a/src/Connection/TcpConnection.php b/src/Connection/TcpConnection.php index edc93cc56..019f3d231 100644 --- a/src/Connection/TcpConnection.php +++ b/src/Connection/TcpConnection.php @@ -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; @@ -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; @@ -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(); } /** @@ -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; } diff --git a/src/Events/Swoole.php b/src/Events/Swoole.php index a951efc7b..ff2cf24bf 100644 --- a/src/Events/Swoole.php +++ b/src/Events/Swoole.php @@ -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); } /**