From 1106f259c2e7c912c0f4c0098bfbe749e9e0f8b7 Mon Sep 17 00:00:00 2001 From: milos Date: Mon, 30 Nov 2020 17:40:22 +0100 Subject: [PATCH] add support to define writetimeout in ms --- src/Monolog/Handler/SocketHandler.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Monolog/Handler/SocketHandler.php b/src/Monolog/Handler/SocketHandler.php index 2861e67d..698360b7 100644 --- a/src/Monolog/Handler/SocketHandler.php +++ b/src/Monolog/Handler/SocketHandler.php @@ -352,10 +352,11 @@ class SocketHandler extends AbstractProcessingHandler } } - private function writingIsTimedOut(int $sent): bool + private function writingIsTimedOut($sent) { - $writingTimeout = (int) floor($this->writingTimeout); - if (0 === $writingTimeout) { + // convert to ms + $writingTimeoutMs = $this->writingTimeout * 1000; + if (0 === $writingTimeoutMs) { return false; } @@ -368,7 +369,10 @@ class SocketHandler extends AbstractProcessingHandler usleep(100); } - if ((time() - $this->lastWritingAt) >= $writingTimeout) { + // convert to ms + $lastWritingMs = (time() - $this->lastWritingAt) * 1000; + + if ($lastWritingMs >= $writingTimeoutMs) { $this->closeSocket(); return true;