From 4c8c5ac239bfba72a46f1cd830bc368cc63a5499 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Fri, 9 Jul 2021 10:36:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- System/Pool/ClientsPool.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/System/Pool/ClientsPool.php b/System/Pool/ClientsPool.php index 933d30ef..a0dfef40 100644 --- a/System/Pool/ClientsPool.php +++ b/System/Pool/ClientsPool.php @@ -83,7 +83,9 @@ class ClientsPool extends Component Timer::clear($this->creates); foreach (static::$_connections as $channel) { $this->flush($channel, 0); + $channel->close(); } + static::$_connections = []; $this->creates = -1; } else { $this->heartbeat_flush(); @@ -134,7 +136,6 @@ class ClientsPool extends Component public function flush($channel, $retain_number) { $this->pop($channel, $retain_number); - static::$_connections = []; } @@ -183,12 +184,16 @@ class ClientsPool extends Component * @param $name * @return Channel * @throws ConfigException + * @throws Exception */ private function getChannel($name): Channel { if (!isset(static::$_connections[$name])) { static::$_connections[$name] = new Channel(Config::get('databases.pool.max', 10)); } + if (static::$_connections[$name]->errCode == SWOOLE_CHANNEL_CLOSED){ + throw new Exception('Channel is Close.'); + } if ($this->creates === -1) { $this->creates = Timer::tick(60000, [$this, 'Heartbeat_detection']); }