mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-06 21:26:43 +02:00
Simplify timeout handling and really allow millisecond precision, refs #1517
This commit is contained in:
@@ -35,6 +35,7 @@ class SocketHandler extends AbstractProcessingHandler
|
|||||||
private $persistent = false;
|
private $persistent = false;
|
||||||
private $errno;
|
private $errno;
|
||||||
private $errstr;
|
private $errstr;
|
||||||
|
/** @var ?float */
|
||||||
private $lastWritingAt;
|
private $lastWritingAt;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -355,13 +356,12 @@ class SocketHandler extends AbstractProcessingHandler
|
|||||||
private function writingIsTimedOut(int $sent): bool
|
private function writingIsTimedOut(int $sent): bool
|
||||||
{
|
{
|
||||||
// convert to ms
|
// convert to ms
|
||||||
$writingTimeoutMs = $this->writingTimeout * 1000;
|
if (0 === $this->writingTimeout) {
|
||||||
if (0 === $writingTimeoutMs) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($sent !== $this->lastSentBytes) {
|
if ($sent !== $this->lastSentBytes) {
|
||||||
$this->lastWritingAt = time();
|
$this->lastWritingAt = microtime(true);
|
||||||
$this->lastSentBytes = $sent;
|
$this->lastSentBytes = $sent;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -369,10 +369,7 @@ class SocketHandler extends AbstractProcessingHandler
|
|||||||
usleep(100);
|
usleep(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert to ms
|
if ((microtime(true) - $this->lastWritingAt) >= $this->writingTimeout) {
|
||||||
$lastWritingMs = (time() - $this->lastWritingAt) * 1000;
|
|
||||||
|
|
||||||
if ($lastWritingMs >= $writingTimeoutMs) {
|
|
||||||
$this->closeSocket();
|
$this->closeSocket();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Reference in New Issue
Block a user