summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-23 14:58:47 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-23 14:58:47 +0000
commitf9adadc5e610360850b3a4bd9a43e928d1c78bb1 (patch)
treec4e34627f259595f6a990c9326ba104dfedfbbf8 /io.c
parentf4166e2dd7a4d9be95f160e19303ddeeb5d27ab4 (diff)
rb_readwrite_syserr_fail
* io.c (rb_readwrite_syserr_fail): works with the given errno than thread local errno. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53265 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/io.c b/io.c
index 976dd8f412..2bf7cd7512 100644
--- a/io.c
+++ b/io.c
@@ -2474,9 +2474,6 @@ rb_io_set_nonblock(rb_io_t *fptr)
#endif
}
-void
-rb_readwrite_sys_fail(int writable, const char *mesg);
-
struct read_internal_arg {
int fd;
char *str_ptr;
@@ -2546,7 +2543,8 @@ io_getpartial(int argc, VALUE *argv, VALUE io, VALUE opts, int nonblock)
if (no_exception_p(opts))
return sym_wait_readable;
else
- rb_readwrite_sys_fail(RB_IO_WAIT_READABLE, "read would block");
+ rb_readwrite_syserr_fail(RB_IO_WAIT_READABLE,
+ e, "read would block");
}
rb_syserr_fail_path(e, fptr->pathv);
}
@@ -2671,7 +2669,8 @@ io_read_nonblock(VALUE io, VALUE length, VALUE str, VALUE ex)
int e = errno;
if ((e == EWOULDBLOCK || e == EAGAIN)) {
if (ex == Qfalse) return sym_wait_readable;
- rb_readwrite_sys_fail(RB_IO_WAIT_READABLE, "read would block");
+ rb_readwrite_syserr_fail(RB_IO_WAIT_READABLE,
+ e, "read would block");
}
rb_syserr_fail_path(e, fptr->pathv);
}
@@ -2713,7 +2712,7 @@ io_write_nonblock(VALUE io, VALUE str, VALUE ex)
return sym_wait_writable;
}
else {
- rb_readwrite_sys_fail(RB_IO_WAIT_WRITABLE, "write would block");
+ rb_readwrite_syserr_fail(RB_IO_WAIT_WRITABLE, e, "write would block");
}
}
rb_syserr_fail_path(e, fptr->pathv);
@@ -11964,10 +11963,15 @@ argf_write(VALUE argf, VALUE str)
}
void
-rb_readwrite_sys_fail(int writable, const char *mesg)
+rb_readwrite_sys_fail(enum rb_io_wait_readwrite writable, const char *mesg)
+{
+ rb_readwrite_syserr_fail(writable, errno, mesg);
+}
+
+void
+rb_readwrite_syserr_fail(enum rb_io_wait_readwrite writable, int n, const char *mesg)
{
VALUE arg;
- int n = errno;
arg = mesg ? rb_str_new2(mesg) : Qnil;
if (writable == RB_IO_WAIT_WRITABLE) {
switch (n) {