@@ -264,7 +264,7 @@ class Worker
264264 *
265265 * @var bool
266266 */
267- protected bool $ pauseAccept = true ;
267+ protected ? bool $ pauseAccept = null ;
268268
269269 /**
270270 * Is worker stopping ?
@@ -2432,10 +2432,10 @@ public static function safeEcho(string $msg, bool $decorated = false): void
24322432 /**
24332433 * Listen.
24342434 *
2435- * @param $autoAccept
2435+ * @param bool $autoAccept
24362436 * @return void
24372437 */
2438- public function listen ($ autoAccept = true ): void
2438+ public function listen (bool $ autoAccept = true ): void
24392439 {
24402440 if (!$ this ->socketName ) {
24412441 return ;
@@ -2581,7 +2581,7 @@ protected function parseSocketAddress(): ?string
25812581 */
25822582 public function pauseAccept (): void
25832583 {
2584- if (static ::$ globalEvent !== null && $ this ->pauseAccept === false && $ this ->mainSocket !== null ) {
2584+ if (static ::$ globalEvent !== null && ! $ this ->pauseAccept && $ this ->mainSocket !== null ) {
25852585 static ::$ globalEvent ->offReadable ($ this ->mainSocket );
25862586 $ this ->pauseAccept = true ;
25872587 }
@@ -2595,7 +2595,7 @@ public function pauseAccept(): void
25952595 public function resumeAccept (): void
25962596 {
25972597 // Register a listener to be notified when server socket is ready to read.
2598- if (static ::$ globalEvent !== null && $ this ->pauseAccept === true && $ this ->mainSocket !== null ) {
2598+ if (static ::$ globalEvent !== null && ( $ this ->pauseAccept === null || $ this -> pauseAccept === true ) && $ this ->mainSocket !== null ) {
25992599 if ($ this ->transport !== 'udp ' ) {
26002600 static ::$ globalEvent ->onReadable ($ this ->mainSocket , $ this ->acceptTcpConnection (...));
26012601 } else {
@@ -2638,7 +2638,9 @@ public function run(): void
26382638 sleep (1 );
26392639 static ::stopAll (250 , $ e );
26402640 } finally {
2641- $ this ->resumeAccept ();
2641+ if ($ this ->pauseAccept === null ) {
2642+ $ this ->resumeAccept ();
2643+ }
26422644 Context::destroy ();
26432645 }
26442646 };
0 commit comments