From 4f2161da5f68f274f116985635aea63b5c0f54d2 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Thu, 12 May 2016 14:54:59 +0200 Subject: [PATCH] Fix notices in NativeReactor; prepare tag 1.2.2 --- CHANGELOG.md | 5 +++++ lib/NativeReactor.php | 13 +++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 694ca330..0da386c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +### 1.2.2 + +- Fix notice in NativeReactor when removing a handle while + an event is waiting for it. (Regression fix from 1.1.1) + ### 1.2.1 - Fix uv_run() potentially exiting earlier than intended, diff --git a/lib/NativeReactor.php b/lib/NativeReactor.php index f262dd1c..63f29f2a 100644 --- a/lib/NativeReactor.php +++ b/lib/NativeReactor.php @@ -241,16 +241,21 @@ private function selectActionableStreams($timeout) { if (!@stream_select($r, $w, $e, $sec, $usec)) { return; } + // check for if (!empty($watchers[$streamId])) as they may have been removed during another callback foreach ($r as $stream) { $streamId = (int) $stream; - foreach ($this->readWatchers[$streamId] as $watcherId => $watcher) { - $this->doIoCallback($watcherId, $watcher, $stream); + if (!empty($this->readWatchers[$streamId])) { + foreach ($this->readWatchers[$streamId] as $watcherId => $watcher) { + $this->doIoCallback($watcherId, $watcher, $stream); + } } } foreach ($w as $stream) { $streamId = (int) $stream; - foreach ($this->writeWatchers[$streamId] as $watcherId => $watcher) { - $this->doIoCallback($watcherId, $watcher, $stream); + if (!empty($this->writeWatchers[$streamId])) { + foreach ($this->writeWatchers[$streamId] as $watcherId => $watcher) { + $this->doIoCallback($watcherId, $watcher, $stream); + } } } }