From 580c3f4ffe9608d2beb56d418c68b3b112420e76 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 10 Nov 2019 12:49:51 +0000 Subject: another bulk of composer updates (cherry picked from commit 6685381fd8db507493c3d7c1793f8c05c681bbce) --- vendor/sabre/event/lib/Loop/Loop.php | 40 ++++++++++++++---------------------- 1 file changed, 15 insertions(+), 25 deletions(-) (limited to 'vendor/sabre/event/lib/Loop/Loop.php') diff --git a/vendor/sabre/event/lib/Loop/Loop.php b/vendor/sabre/event/lib/Loop/Loop.php index 86ee7c8b0..301fe8920 100644 --- a/vendor/sabre/event/lib/Loop/Loop.php +++ b/vendor/sabre/event/lib/Loop/Loop.php @@ -1,4 +1,4 @@ -runNextTicks(); $nextTimeout = $this->runTimers(); @@ -284,7 +271,7 @@ class Loop { * * If there's no more pending timers, this function returns null. * - * @return float + * @return float|null */ protected function runTimers() { @@ -295,7 +282,7 @@ class Loop { // Add the last timer back to the array. if ($timer) { $this->timers[] = $timer; - return $timer[0] - microtime(true); + return max(0, $timer[0] - microtime(true)); } } @@ -303,7 +290,10 @@ class Loop { /** * Runs all pending stream events. * - * @param float $timeout + * If $timeout is 0, it will return immediately. If $timeout is null, it + * will wait indefinitely. + * + * @param float|null timeout */ protected function runStreams($timeout) { @@ -312,7 +302,7 @@ class Loop { $read = $this->readStreams; $write = $this->writeStreams; $except = null; - if (stream_select($read, $write, $except, null, $timeout)) { + if (stream_select($read, $write, $except, ($timeout === null) ? null : 0, $timeout ? (int)($timeout * 1000000) : 0)) { // See PHP Bug https://bugs.php.net/bug.php?id=62452 // Fixed in PHP7 @@ -328,7 +318,7 @@ class Loop { } } elseif ($this->running && ($this->nextTick || $this->timers)) { - usleep($timeout !== null ? $timeout * 1000000 : 200000); + usleep($timeout !== null ? intval($timeout * 1000000) : 200000); } } -- cgit v1.2.3