[前][次][番号順一覧][スレッド一覧]

ruby-changes:72149

From: Samuel <ko1@a...>
Date: Mon, 13 Jun 2022 13:12:39 +0900 (JST)
Subject: [ruby-changes:72149] 425a46131a (master): Handle case where write result is zero.

https://git.ruby-lang.org/ruby.git/commit/?id=425a46131a

From 425a46131a029390cd693242e621f6632c76cc42 Mon Sep 17 00:00:00 2001
From: Samuel Williams <samuel.williams@o...>
Date: Mon, 13 Jun 2022 15:33:54 +1200
Subject: Handle case where write result is zero.

---
 io.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/io.c b/io.c
index d403df399c..170ccc690a 100644
--- a/io.c
+++ b/io.c
@@ -1620,6 +1620,12 @@ io_binwrite_string(VALUE arg) https://github.com/ruby/ruby/blob/trunk/io.c#L1620
         // 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 (result > 0) {
             if ((size_t)result == remaining) break;
             ptr += result;
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]