1
0
mirror of https://github.com/danog/amp.git synced 2025-01-22 13:21:16 +01:00

Fix issue with the loop not terminating with only unreferenced watchers

This commit is contained in:
Bob Weinand 2017-07-09 09:28:32 +02:00
parent bb1db1609f
commit 5e93318d85
2 changed files with 11 additions and 1 deletions

View File

@ -127,7 +127,7 @@ abstract class Driver {
}
}
$this->dispatch(empty($this->nextTickQueue) && empty($this->enableQueue) && $this->running);
$this->dispatch(empty($this->nextTickQueue) && empty($this->enableQueue) && $this->running && !$this->isEmpty());
}
/**

View File

@ -98,6 +98,16 @@ abstract class DriverTest extends TestCase {
});
}
public function testLoopTerminatesWithOnlyUnreferencedWatchers() {
$this->start(function (Driver $loop) use (&$end) {
$loop->unreference($loop->onReadable(STDIN, function() {}));
$w = $loop->delay(10000000, function() {});
$loop->defer(function() use ($loop, $w) { $loop->cancel($w); });
$end = true;
});
$this->assertTrue($end);
}
/** This MUST NOT have a "test" prefix, otherwise it's executed as test and marked as risky. */
public function checkForSignalCapability() {
try {