This commit is contained in:
2021-05-25 10:18:42 +08:00
parent 3abbfc8e22
commit 7bc6cb78b8
+5 -4
View File
@@ -173,7 +173,7 @@ abstract class Pool extends Component
return $this->createClient($name, $callback); return $this->createClient($name, $callback);
} }
$channel = static::$_items[$name] ?? new Channel($this->max); $channel = static::$_items[$name] ?? new Channel($this->max);
if (!isset(static::$_items[$name])) { if (!((static::$_items[$name] ?? null) instanceof Channel)) {
static::$_items[$name] = $channel; static::$_items[$name] = $channel;
} }
if ($channel->isEmpty()) { if ($channel->isEmpty()) {
@@ -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);
} }