This commit is contained in:
2021-05-20 18:43:44 +08:00
parent 3abbfc8e22
commit 6fb5bb1d41
+7 -5
View File
@@ -121,12 +121,12 @@ abstract class Pool extends Component
/** /**
* @param $channel * @param Channel $channel
* @param $name * @param $name
* @param $retain_number * @param $retain_number
* @throws Exception * @throws Exception
*/ */
protected function pop($channel, $name, $retain_number): void protected function pop(Channel $channel, $name, $retain_number): void
{ {
if (Coroutine::getCid() === -1) { if (Coroutine::getCid() === -1) {
return; return;
@@ -296,11 +296,12 @@ abstract class Pool extends Component
if (Coroutine::getCid() === -1) { if (Coroutine::getCid() === -1) {
return; return;
} }
$channel = static::$_items[$name] ?? new Channel($this->max);
if (!isset(static::$_items[$name])) { if (!isset(static::$_items[$name])) {
static::$_items[$name] = new Channel($this->max); static::$_items[$name] = $channel;
} }
if (!static::$_items[$name]->isFull()) { if (!$channel->isFull()) {
static::$_items[$name]->push($client); $channel->push($client);
} }
unset($client); unset($client);
} }
@@ -320,6 +321,7 @@ abstract class Pool extends Component
if ($this->creates > -1) { if ($this->creates > -1) {
Timer::clear($this->creates); Timer::clear($this->creates);
} }
$channel->close();
static::$_items[$name] = null; static::$_items[$name] = null;
} }