1
0
mirror of https://github.com/danog/amp.git synced 2024-11-30 04:29:08 +01:00

Use correct uv flags to prevent UvReactor::tick() from hanging in edge-case scenarios

This commit is contained in:
Daniel Lowrey 2015-08-11 19:57:59 -04:00
parent 7df9b175ef
commit 3d1fde0812
2 changed files with 17 additions and 3 deletions

13
CHANGELOG Normal file
View File

@ -0,0 +1,13 @@
# dev
- n/a
### 1.0.1
- Fix bug preventing UvReactor::tick() from returning when no
events are ready for a single active IO watcher.
1.0.0
-----
- Initial stable API release

View File

@ -90,7 +90,8 @@ class UvReactor implements Reactor {
if (empty($this->keepAliveCount) || $this->state <= self::STOPPED) {
break;
}
\uv_run($this->loop, \UV::RUN_DEFAULT | (empty($this->immediates) ? \UV::RUN_ONCE : \UV::RUN_NOWAIT));
$flags = \UV::RUN_ONCE | ($this->immediates ? \UV::RUN_NOWAIT : 0);
\uv_run($this->loop, $flags);
}
\gc_collect_cycles();
@ -148,8 +149,8 @@ class UvReactor implements Reactor {
}
// Check the conditional again because a manual stop() could've changed the state
if ($this->state) {
$flags = $noWait || !empty($this->immediates) ? (\UV::RUN_NOWAIT | \UV::RUN_ONCE) : \UV::RUN_ONCE;
if ($this->state > 0) {
$flags = ($noWait || $this->immediates) ? (\UV::RUN_DEFAULT | \UV::RUN_NOWAIT) : \UV::RUN_ONCE;
\uv_run($this->loop, $flags);
}