aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
authorSamuel Williams <samuel.williams@oriontransfer.co.nz>2024-02-01 15:27:44 +1300
committerGitHub <noreply@github.com>2024-02-01 15:27:44 +1300
commit2554c5d3b8738a248cedb2fea96dfab9fbe19417 (patch)
treedd8723d58f54ad8116b02fc34b57992a5b0a3507 /io.c
parentda33c5ac9fe12fd356b561ba57607aa04da8493c (diff)
downloadruby-2554c5d3b8738a248cedb2fea96dfab9fbe19417.tar.gz
Don't wait in `io_binwrite_string` if not necessary. (#9792)
Diffstat (limited to 'io.c')
-rw-r--r--io.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/io.c b/io.c
index 54952c1a2f..7d8b9bf410 100644
--- a/io.c
+++ b/io.c
@@ -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;