From c6411cc23f20b45d9957366fa8d5a83bf2e005d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Mon, 4 Jan 2021 18:54:27 +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/Abstracts/Pool.php | 4 +++- System/Pool/Connection.php | 2 +- System/Pool/Redis.php | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/System/Abstracts/Pool.php b/System/Abstracts/Pool.php index 7fa0b407..d9e4677e 100644 --- a/System/Abstracts/Pool.php +++ b/System/Abstracts/Pool.php @@ -153,7 +153,9 @@ abstract class Pool extends Component */ public function push(string $name, mixed $client) { - $this->_items[$name]->push([time(), $client]); + if (!$this->_items[$name]->isFull()) { + $this->_items[$name]->push([time(), $client]); + } unset($client); } diff --git a/System/Pool/Connection.php b/System/Pool/Connection.php index 3bb9d8ca..79cfb83a 100644 --- a/System/Pool/Connection.php +++ b/System/Pool/Connection.php @@ -206,7 +206,7 @@ class Connection extends Pool if (Context::hasContext($coroutineName)) { return Context::getContext($coroutineName); } - if ($this->size($coroutineName) < 1 && $this->hasCreate[$coroutineName] < $this->max) { + if ($this->size($coroutineName) < 1) { $this->newClient($config, $coroutineName); } [$time, $connections] = $this->get($coroutineName); diff --git a/System/Pool/Redis.php b/System/Pool/Redis.php index da6ed9db..b6a3258a 100644 --- a/System/Pool/Redis.php +++ b/System/Pool/Redis.php @@ -57,7 +57,7 @@ class Redis extends Pool */ public function getByChannel($coroutineName, $config): mixed { - if ($this->_create < $this->max && !$this->hasItem($coroutineName)) { + if (!$this->hasItem($coroutineName)) { $this->newClient($config, $coroutineName); } [$time, $clients] = $this->get($coroutineName);