summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-04-30 02:17:03 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-04-30 02:17:03 (GMT)
commit7727b22eb1dd2aab3127a0b4fdb6ee52aedf358e (patch)
tree5f0dd96fe72ce2fc777e77425582f361b1f19f6d /io.c
parent9cd4834810f4cb3bf093f07666e4cba0a2a66f94 (diff)
io.c: workaround for EPROTOTYPE
* io.c (internal_write_func, internal_writev_func): retry at unexpected EPROTOTYPE on macOS, to get rid of a kernel bug. [ruby-core:86690] [Bug #14713] * ext/socket/init.c (rsock_{sendto,send,write}_blocking): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63304 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/io.c b/io.c
index 5e921a5..c045773 100644
--- a/io.c
+++ b/io.c
@@ -945,11 +945,18 @@ internal_read_func(void *ptr)
return read(iis->fd, iis->buf, iis->capa);
}
+#if defined __APPLE__
+# define do_write_retry(code) do {ret = code;} while (ret == -1 && errno == EPROTOTYPE)
+#else
+# define do_write_retry(code) ret = code
+#endif
static VALUE
internal_write_func(void *ptr)
{
struct io_internal_write_struct *iis = ptr;
- return write(iis->fd, iis->buf, iis->capa);
+ ssize_t ret;
+ do_write_retry(write(iis->fd, iis->buf, iis->capa));
+ return (VALUE)ret;
}
static void*
@@ -963,7 +970,9 @@ static VALUE
internal_writev_func(void *ptr)
{
struct io_internal_writev_struct *iis = ptr;
- return writev(iis->fd, iis->iov, iis->iovcnt);
+ ssize_t ret;
+ do_write_retry(writev(iis->fd, iis->iov, iis->iovcnt));
+ return (VALUE)ret;
}
#endif