This commit is contained in:
2023-08-25 09:39:52 +08:00
parent 5f7a63a2c0
commit 29813082f8
+6 -4
View File
@@ -5,6 +5,7 @@ namespace Kiri\Pool;
use Exception; use Exception;
use Kiri\Di\Context;
/** /**
@@ -69,7 +70,7 @@ class Pool implements PoolInterface
throw new Exception('Channel is not exists.'); throw new Exception('Channel is not exists.');
} }
$channel = $this->_connections[$name]; $channel = $this->_connections[$name];
if ($channel == null || $channel->isClose()) { if ($channel->isClose()) {
$channel->reconnect(); $channel->reconnect();
} }
return $channel; return $channel;
@@ -189,11 +190,12 @@ class Pool implements PoolInterface
*/ */
public function close(string $name): void public function close(string $name): void
{ {
$channel = $this->_connections[$name] ?? null; if (!isset($this->_connections[$name])) {
if ($channel === null) {
return; return;
} }
$this->_connections[$name] = null; if (Context::inCoroutine()) {
$this->_connections[$name]->close();
}
} }