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); } }