Skip to content

Commit

Permalink
bug #22787 [MonologBridge] Fix the Monlog ServerLogHandler from Hangi…
Browse files Browse the repository at this point in the history
…ng 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
  • Loading branch information
fabpot committed May 20, 2017
2 parents 649ad8c + be60aa4 commit 159f3c5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Symfony/Bridge/Monolog/Handler/ServerLogHandler.php
Expand Up @@ -54,12 +54,12 @@ public function handle(array $record)

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

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

// Let's retry: the persistent connection might just be stale
if ($this->socket = $this->createSocket()) {
fwrite($this->socket, $recordFormatted);
stream_socket_sendto($this->socket, $recordFormatted);
}
}
} finally {
Expand Down

0 comments on commit 159f3c5

Please sign in to comment.