Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0651e7c

Browse filesBrowse files
bug #28813 Fix for race condition in console output stream write (rudolfratusinski)
This PR was merged into the 2.8 branch. Discussion ---------- Fix for race condition in console output stream write | Q | A | ------------- | --- | Branch? | 2.8 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | In high throughput environments writing `message` and `PHP_EOL` separately causes race condition issues, where messages might be written in order - message - message - EOL - EOL instead of - message - EOL - message - EOL An example below is a laravel application log tail of queue workers (multiple app instances writing to the same log file) handled by supervisor. Before: ![ezgif-1-77388f9210cf](https://user-images.githubusercontent.com/2752769/46792349-bec13180-cd75-11e8-8f91-92f05762f964.gif) After: ![ezgif-1-0b839d642644](https://user-images.githubusercontent.com/2752769/46792420-e617fe80-cd75-11e8-9414-4bfc85d9c569.gif) Commits ------- 428dea6 Fix for race condition in console output stream write
2 parents 7d9ae2f + 428dea6 commit 0651e7c
Copy full SHA for 0651e7c

File tree

Expand file treeCollapse file tree

1 file changed

+5
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+5
-1
lines changed

‎src/Symfony/Component/Console/Output/StreamOutput.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Output/StreamOutput.php
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,11 @@ public function getStream()
7070
*/
7171
protected function doWrite($message, $newline)
7272
{
73-
if (false === @fwrite($this->stream, $message) || ($newline && (false === @fwrite($this->stream, PHP_EOL)))) {
73+
if ($newline) {
74+
$message .= PHP_EOL;
75+
}
76+
77+
if (false === @fwrite($this->stream, $message)) {
7478
// should never happen
7579
throw new RuntimeException('Unable to write output.');
7680
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.