Skip to content

Commit

Permalink
Update SwooleContextHandler.php (#209)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
anoxia authored Nov 10, 2023
1 parent 3d811bd commit 3db80bd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Context/Swoole/src/SwooleContextHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 3db80bd

Please sign in to comment.