Skip to content

Commit

Permalink
Check __destruct isSafe
Browse files Browse the repository at this point in the history
  • Loading branch information
walkor committed Nov 23, 2024
1 parent e48b410 commit 517ef66
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/Connection/TcpConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,13 @@ class TcpConnection extends ConnectionInterface implements JsonSerializable
*/
public ?Request $request = null;

/**
* Is safe.
*
* @var bool
*/
protected bool $isSafe = true;

/**
* Default send buffer size.
*
Expand Down Expand Up @@ -1102,6 +1109,16 @@ public function jsonSerialize(): array
];
}

/**
* __wakeup.
*
* @return void
*/
public function __wakeup()
{
$this->isSafe = false;
}

/**
* Destruct.
*
Expand All @@ -1110,6 +1127,9 @@ public function jsonSerialize(): array
public function __destruct()
{
static $mod;
if (!$this->isSafe) {
return;
}
self::$statistics['connection_count']--;
if (Worker::getGracefulStop()) {
$mod ??= ceil((self::$statistics['connection_count'] + 1) / 3);
Expand Down

0 comments on commit 517ef66

Please sign in to comment.