Skip to content

Don't wait in io_binwrite_string if not necessary. #9792

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions io.c
Original file line number Diff line number Diff line change
Expand Up @@ -1800,13 +1800,11 @@ io_binwrite_string(VALUE arg)
// Write as much as possible:
ssize_t result = io_binwrite_string_internal(p->fptr, ptr, remaining);

// If only the internal buffer is written, result will be zero [bytes of given data written]. This means we
// should try again.
if (result == 0) {
errno = EWOULDBLOCK;
// If only the internal buffer is written, result will be zero [bytes of given data written]. This means we
// should try again immediately.
}

if (result > 0) {
else if (result > 0) {
if ((size_t)result == remaining) break;
ptr += result;
remaining -= result;
Expand Down