Skip to content

Commit

Permalink
Merge remote-tracking branch 'milos-silni/add-support-ms-writetimeout…
Browse files Browse the repository at this point in the history
…' into main
  • Loading branch information
Seldaek committed Dec 14, 2020
2 parents ff4378d + 38367d3 commit 1850160
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Monolog/Handler/SocketHandler.php
Expand Up @@ -354,8 +354,9 @@ private function writeToSocket(string $data): void

private function writingIsTimedOut(int $sent): bool
{
$writingTimeout = (int) floor($this->writingTimeout);
if (0 === $writingTimeout) {
// convert to ms
$writingTimeoutMs = $this->writingTimeout * 1000;
if (0 === $writingTimeoutMs) {
return false;
}

Expand All @@ -368,7 +369,10 @@ private function writingIsTimedOut(int $sent): bool
usleep(100);
}

if ((time() - $this->lastWritingAt) >= $writingTimeout) {
// convert to ms
$lastWritingMs = (time() - $this->lastWritingAt) * 1000;

if ($lastWritingMs >= $writingTimeoutMs) {
$this->closeSocket();

return true;
Expand Down

0 comments on commit 1850160

Please sign in to comment.