8000 bug #22787 [MonologBridge] Fix the Monlog ServerLogHandler from Hangi… · symfony/symfony@159f3c5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 159f3c5

Browse files
committed
bug #22787 [MonologBridge] Fix the Monlog ServerLogHandler from Hanging on Windows (ChadSikorra)
This PR was squashed before being merged into the 3.3 branch (closes #22787). Discussion ---------- [MonologBridge] Fix the Monlog ServerLogHandler from Hanging on Windows | Q | A | ------------- | --- | Branch? | 3.3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | - | Fixed tickets | #22712 | License | MIT This resolves the issue discussed in #22712. This works on both Windows and Linux. Specifically it removes the additional hanging that was caused on Windows when attempting to write/close a TCP socket that's not open on the other end in asynchronous mode. Commits ------- be60aa4 [MonologBridge] Fix the Monlog ServerLogHandler from Hanging on Windows
2 parents 649ad8c + be60aa4 commit 159f3c5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Symfony/Bridge/Monolog/Handler/ServerLogHandler.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ public function handle(array $record)
5454

5555
$recordFormatted = $this->formatRecord($record);
5656

57-
if (!fwrite($this->socket, $recordFormatted)) {
58-
fclose($this->socket);
57+
if (-1 === stream_socket_sendto($this->socket, $recordFormatted)) {
58+
stream_socket_shutdown($this->socket, STREAM_SHUT_RDWR);
5959

6060
// Let's retry: the persistent connection might just be stale
6161
if ($this->socket = $this->createSocket()) {
62-
fwrite($this->socket, $recordFormatted);
62+
stream_socket_sendto($this->socket, $recordFormatted);
6363
}
6464
}
6565
} finally {

0 commit comments

Comments
 (0)
0