From 86d7ebba305bcb9ac0b0239b3489141f826f0d98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B7=AF=E6=98=93=E6=B8=AF?= Date: Fri, 10 Nov 2023 10:52:01 +0800 Subject: [PATCH] Update SwooleContextHandler.php If the exception in the coroutine is not caught or other unknown circumstances, the code stack will run in a non-coroutine. At this time, Coroutine::getPcid($pcid) will return false, and SwooleContextHandler::isForked(int id) will raise a TypeError. fatal error --- src/Context/Swoole/src/SwooleContextHandler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Context/Swoole/src/SwooleContextHandler.php b/src/Context/Swoole/src/SwooleContextHandler.php index 4e334282..d7bc3eca 100644 --- a/src/Context/Swoole/src/SwooleContextHandler.php +++ b/src/Context/Swoole/src/SwooleContextHandler.php @@ -28,7 +28,7 @@ public function switchToActiveCoroutine(): void { $cid = Coroutine::getCid(); if ($cid !== -1 && !$this->isForked($cid)) { - for ($pcid = $cid; ($pcid = Coroutine::getPcid($pcid)) !== -1 && !$this->isForked($pcid);) { + for ($pcid = $cid; ($pcid = Coroutine::getPcid($pcid)) !== -1 && Coroutine::exists($pcid) && !$this->isForked($pcid);) { } $this->storage->switch($pcid);