From c3a3551ba3be50b35ce4e6b7b772dafd570a3075 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Fri, 14 Jan 2022 15:52:38 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"=E6=94=B9=E5=90=8D"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit fdf58326 --- kiri-engine/Pool/Connection.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/kiri-engine/Pool/Connection.php b/kiri-engine/Pool/Connection.php index 6808301f..bf277cf8 100644 --- a/kiri-engine/Pool/Connection.php +++ b/kiri-engine/Pool/Connection.php @@ -6,10 +6,10 @@ namespace Kiri\Pool; use Closure; use Database\Mysql\PDO; use Exception; +use Kiri; use Kiri\Abstracts\Component; use Kiri\Abstracts\Config; use Kiri\Context; -use Kiri; use Swoole\Error; use Throwable; @@ -126,7 +126,11 @@ class Connection extends Component */ public function initConnections($name, $isMaster, $max) { - $this->getPool()->initConnections($name, $isMaster, $max); + $pool = $this->getPool(); + $pool->initConnections($name, $isMaster, $max); + for ($i = 0; $i < $max; $i++) { + $pool->push($name, $this->create($name, [])); + } } @@ -184,7 +188,7 @@ class Connection extends Component } else { $result = true; } - } catch (Error | Throwable $exception) { + } catch (Error|Throwable $exception) { $result = $this->addError($exception, 'mysql'); } finally { return $result;