@@ -137,18 +137,6 @@ public function futureTick(callable $listener)
137137 $ this ->futureTickQueue ->add ($ listener );
138138 }
139139
140- /**
141- * {@inheritdoc}
142- */
143- public function tick ()
144- {
145- $ this ->futureTickQueue ->tick ();
146-
147- $ this ->timers ->tick ();
148-
149- $ this ->waitForStreamActivity (0 );
150- }
151-
152140 /**
153141 * {@inheritdoc}
154142 */
@@ -203,7 +191,12 @@ private function waitForStreamActivity($timeout)
203191 $ read = $ this ->readStreams ;
204192 $ write = $ this ->writeStreams ;
205193
206- $ this ->streamSelect ($ read , $ write , $ timeout );
194+ $ available = $ this ->streamSelect ($ read , $ write , $ timeout );
195+ if (false === $ available ) {
196+ // if a system call has been interrupted,
197+ // we cannot rely on it's outcome
198+ return ;
199+ }
207200
208201 foreach ($ read as $ stream ) {
209202 $ key = (int ) $ stream ;
@@ -230,17 +223,19 @@ private function waitForStreamActivity($timeout)
230223 * @param array &$write An array of write streams to select upon.
231224 * @param integer|null $timeout Activity timeout in microseconds, or null to wait forever.
232225 *
233- * @return integer The total number of streams that are ready for read/write.
226+ * @return integer|false The total number of streams that are ready for read/write.
227+ * Can return false if stream_select() is interrupted by a signal.
234228 */
235229 protected function streamSelect (array &$ read , array &$ write , $ timeout )
236230 {
237231 if ($ read || $ write ) {
238232 $ except = null ;
239233
240- return stream_select ($ read , $ write , $ except , $ timeout === null ? null : 0 , $ timeout );
234+ // suppress warnings that occur, when stream_select is interrupted by a signal
235+ return @stream_select ($ read , $ write , $ except , $ timeout === null ? null : 0 , $ timeout );
241236 }
242237
243- usleep ($ timeout );
238+ $ timeout && usleep ($ timeout );
244239
245240 return 0 ;
246241 }
0 commit comments