From 53e0163388a9bd61d01c05538aead6e1a1c52ad6 Mon Sep 17 00:00:00 2001 From: "as2252258@163.com" Date: Mon, 6 Sep 2021 02:28:06 +0800 Subject: [PATCH] 111 --- core/Pool/Pool.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/core/Pool/Pool.php b/core/Pool/Pool.php index f62091a4..542afc1b 100644 --- a/core/Pool/Pool.php +++ b/core/Pool/Pool.php @@ -48,9 +48,11 @@ class Pool extends Component protected function pop(Channel $channel, $retain_number): void { while ($channel->length() > $retain_number) { - $connection = $channel->pop(); - if ($connection instanceof StopHeartbeatCheck) { - $connection->stopHeartbeatCheck(); + if (Context::inCoroutine()) { + $connection = $channel->pop(); + if ($connection instanceof StopHeartbeatCheck) { + $connection->stopHeartbeatCheck(); + } } } } @@ -217,8 +219,8 @@ class Pool extends Component if (!isset(static::$_connections[$name])) { return; } - $channel = static::$_connections[$name]; - $this->pop($channel, 0); + static::$_connections[$name] = null; + unset(static::$_connections[$name]); }