Skip to content

Commit

Permalink
Fix bug causing infinite busy wait with active immediates
Browse files Browse the repository at this point in the history
  • Loading branch information
bwoebi committed Aug 20, 2015
1 parent e882ecc commit 8f884b0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
- Fix issue in NativeReactor capable of causing keep alive
counter corruption when a watcher was cancelled inside its
own callback.
- Fix issue in UvReactor with libuv >= 1.1.0 causing busy loop
with immediates present, but no watchers being triggered.

### 1.0.2

Expand Down
6 changes: 2 additions & 4 deletions lib/UvReactor.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ public function run(callable $onStart = null) {
if (empty($this->keepAliveCount) || $this->state <= self::STOPPED) {
break;
}
$flags = \UV::RUN_ONCE | ($this->immediates ? \UV::RUN_NOWAIT : 0);
\uv_run($this->loop, $flags);
\uv_run($this->loop, $this->immediates ? \UV::RUN_NOWAIT : \UV::RUN_ONCE);
}

\gc_collect_cycles();
Expand Down Expand Up @@ -150,8 +149,7 @@ public function tick($noWait = false) {

// Check the conditional again because a manual stop() could've changed the state
if ($this->state > 0) {
$flags = ($noWait || $this->immediates) ? (\UV::RUN_DEFAULT | \UV::RUN_NOWAIT) : \UV::RUN_ONCE;
\uv_run($this->loop, $flags);
\uv_run($this->loop, $noWait || $this->immediates ? \UV::RUN_NOWAIT : \UV::RUN_ONCE);
}

$this->state = self::STOPPED;
Expand Down

0 comments on commit 8f884b0

Please sign in to comment.