Make run-tests.php check for tcp fwrite edge cases - #9242
Merged
Conversation
bukka
reviewed
Aug 4, 2022
TysonAndre
force-pushed
the
run-tests-fwrite-error
branch
from
August 5, 2022 19:53
55325fe to
8cc8300
Compare
bukka
reviewed
Aug 5, 2022
When the recipient is busy or the payload is large, fwrite can block or return a value smaller than the length of the stream. workers in run-tests.php communicates over tcp sockets with the manager. https://cirrus-ci.com/task/5315675320221696?logs=tests#L130 showed notices for fwrite/unserialize This is a similar approach to the approach used in https://github.com/phan/phan/blob/v5/src/Phan/LanguageServer/ProtocolStreamWriter.php for the tcp language server writing.
TysonAndre
force-pushed
the
run-tests-fwrite-error
branch
from
August 7, 2022 17:08
8cc8300 to
b015f82
Compare
bukka
approved these changes
Aug 10, 2022
iluuu1994
approved these changes
Sep 29, 2022
| /* Wait for up to 10 seconds for the stream to be ready to write again. */ | ||
| $result = stream_select($read_streams, $write_streams, $except_streams, 10); | ||
| if (!$result) { | ||
| echo "ERROR: send_message() stream_select() failed\n"; |
Member
There was a problem hiding this comment.
Suggested change
| echo "ERROR: send_message() stream_select() failed\n"; | |
| fwrite(STDERR, "ERROR: send_message() stream_select() failed\n"); |
Contributor
Author
There was a problem hiding this comment.
function error(string $message): void
{
echo "ERROR: {$message}\n";
exit(1);
}Nothing else in run-tests.php is printing to STDERR or referencing STDERR yet - starting to do that would introduce an inconsistency with similar error logging.
For anything redirecting to a log file, the existing behavior of printing to stdout seems fine, especially since there's no machine-readable output format for run-tests.php as an option
| } | ||
| $n = @fwrite($stream, substr($data, $bytes_written)); | ||
| if ($n === false) { | ||
| echo "ERROR: send_message() Failed to write chunk after stream_select: " . error_get_last()['message'] . "\n"; |
Member
There was a problem hiding this comment.
Suggested change
| echo "ERROR: send_message() Failed to write chunk after stream_select: " . error_get_last()['message'] . "\n"; | |
| fwrite(STDERR, "ERROR: send_message() Failed to write chunk after stream_select: " . error_get_last()['message'] . "\n"); |
adrian-enspired
pushed a commit
to adrian-enspired/php-src
that referenced
this pull request
Aug 4, 2026
When the recipient is busy or the payload is large, fwrite can block or return a value smaller than the length of the stream. workers in run-tests.php communicates over tcp sockets with the manager. https://cirrus-ci.com/task/5315675320221696?logs=tests#L130 showed notices for fwrite/unserialize This is a similar approach to the approach used in https://github.com/phan/phan/blob/v5/src/Phan/LanguageServer/ProtocolStreamWriter.php for the tcp language server writing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the recipient is busy or the payload is large, fwrite can block
or return a value smaller than the length of the stream.
workers in run-tests.php communicates over tcp sockets with the manager.
https://cirrus-ci.com/task/5315675320221696?logs=tests#L130
showed notices for fwrite/unserialize
This is a similar approach to that used in
https://github.com/phan/phan/blob/v5/src/Phan/LanguageServer/ProtocolStreamWriter.php
for the tcp language server writing.
Reopening #8023