From fabacd33eada1df1e21b10044f54cce4b0c8bd23 Mon Sep 17 00:00:00 2001 From: hsldymq Date: Wed, 24 Apr 2019 19:21:29 +0800 Subject: [PATCH] refactor --- src/Dispatcher.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Dispatcher.php b/src/Dispatcher.php index ee979dc..94fd071 100644 --- a/src/Dispatcher.php +++ b/src/Dispatcher.php @@ -587,7 +587,12 @@ private function informWorkersQuit() private function waitChildren() { - while (($pid = pcntl_wait($status, WNOHANG)) > 0) { + $numWorkers = count($this->getWorkerIDs()); + for ($i = 0; $i < $numWorkers; $i++) { + $pid = pcntl_wait($status, WNOHANG); + if ($pid <= 0) { + break; + } $this->clearWorker($this->idMap[$pid] ?? '', $pid); } }