diff --git a/src/utils/src/Coroutine.php b/src/utils/src/Coroutine.php index 6e6063b3e..d6d78e72c 100644 --- a/src/utils/src/Coroutine.php +++ b/src/utils/src/Coroutine.php @@ -46,9 +46,13 @@ class Coroutine * * @see https://github.com/swoole/swoole-src/pull/2669/files#diff-3bdf726b0ac53be7e274b60d59e6ec80R940 */ - public static function parentId(): ?int + public static function parentId(?int $coroutineId = null): ?int { - $cid = SwooleCoroutine::getPcid(); + if ($coroutineId) { + $cid = SwooleCoroutine::getPcid($coroutineId); + } else { + $cid = SwooleCoroutine::getPcid(); + } if ($cid === false) { return null; }