This commit is contained in:
2020-09-06 16:36:04 +08:00
parent 1dacc2598b
commit b54edb28b8
+20 -6
View File
@@ -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);
}
}