From b54edb28b8fcaed0ba11ad343b86624237700c98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Sun, 6 Sep 2020 16:36:04 +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/Connection.php | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/System/Pool/Connection.php b/System/Pool/Connection.php index 2b199d44..ae5b62d0 100644 --- a/System/Pool/Connection.php +++ b/System/Pool/Connection.php @@ -54,13 +54,27 @@ class Connection extends Pool { $channels = $this->getChannels(); foreach ($channels as $name => $channel) { - while ($channel->length() > $retain_number) { - [$timer, $connection] = $channel->pop(); - if ($connection) { - unset($connection); - } - $this->desc($name); + $this->pop($channel, $name, $retain_number); + } + if ($retain_number == 0) { + Timer::clear($this->creates); + } + } + + + /** + * @param $channel + * @param $name + * @param $retain_number + */ + protected function pop($channel, $name, $retain_number) + { + while ($channel->length() > $retain_number) { + [$timer, $connection] = $channel->pop(); + if ($connection) { + unset($connection); } + $this->desc($name); } }