Skip to content

Commit

Permalink
processing timeout fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nekufa committed Feb 2, 2022
1 parent 12aa90c commit c5829ec
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,11 @@ public function process(null|int|float $timeout = 0)
$max = microtime(true) + $timeout;

while (!($line = stream_get_line($this->socket, 1024, "\r\n"))) {
if (microtime(true) > $max) {
$now = microtime(true);
if ($now >= $max) {
return null;
}
// 1ms sleep
$this->logger?->debug('sleep', compact('max', 'now'));
usleep(intval($this->delay * 1_000_000));
}

Expand Down

0 comments on commit c5829ec

Please sign in to comment.