Skip to content

Commit d50de88

Browse files
committed
Fix onSignal porition of testNoMemoryLeak
1 parent e912117 commit d50de88

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/Test.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -433,15 +433,17 @@ function testNoMemoryLeak($type, $args)
433433
$loop->run();
434434
}
435435
if ($type === "onSignal") {
436-
$watchers = [$loop->onSignal(\SIGUSR1, $fn = function ($watcherId, $i) use (&$fn, $loop, &$watchers) {
436+
$sendSignal = function () {
437+
\posix_kill(\getmypid(), \SIGUSR1);
438+
};
439+
$loop->onSignal(\SIGUSR1, $fn = function ($watcherId, $signo, $i) use (&$fn, $loop, $sendSignal) {
437440
if ($i) {
438-
$watchers[] = $loop->onSignal(\SIGUSR1, $fn, --$i);
439-
} else {
440-
foreach ($watchers as $watcher) {
441-
$loop->cancel($watcher);
442-
}
441+
$loop->onSignal(\SIGUSR1, $fn, --$i);
442+
$loop->defer($sendSignal);
443443
}
444-
}, $runs)];
444+
$loop->cancel($watcherId);
445+
}, $runs);
446+
$loop->defer($sendSignal);
445447
$loop->run();
446448
}
447449
};

0 commit comments

Comments
 (0)