summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-03 12:24:07 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-03 12:24:07 +0000
commit877a9a7d994fc9255db33f86d73f08870be8b234 (patch)
treedc02fcffbf0052ebb43282c048b2ac6ed9afd445 /ext
parent8a571111295f8ce1720e10fd2760197951d481c7 (diff)
merges r32062 from trunk into ruby_1_9_2.
-- * ext/socket/unixsocket.c (unix_send_io): race condition fixed. (unix_recv_io): ditto. fixed by Eric Wong. [ruby-core:35574] * test/socket/test_unix.rb: test added for above problem. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@32383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/socket/unixsocket.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/ext/socket/unixsocket.c b/ext/socket/unixsocket.c
index 82893abcfe..d32567c686 100644
--- a/ext/socket/unixsocket.c
+++ b/ext/socket/unixsocket.c
@@ -248,9 +248,10 @@ unix_send_io(VALUE sock, VALUE val)
#endif
arg.fd = fptr->fd;
- rb_thread_fd_writable(arg.fd);
- if ((int)BLOCKING_REGION(sendmsg_blocking, &arg) == -1)
- rb_sys_fail("sendmsg(2)");
+ while ((int)BLOCKING_REGION_FD(sendmsg_blocking, &arg) == -1) {
+ if (!rb_io_wait_writable(arg.fd))
+ rb_sys_fail("sendmsg(2)");
+ }
return Qnil;
}
@@ -334,9 +335,10 @@ unix_recv_io(int argc, VALUE *argv, VALUE sock)
#endif
arg.fd = fptr->fd;
- rb_thread_wait_fd(arg.fd);
- if ((int)BLOCKING_REGION(recvmsg_blocking, &arg) == -1)
- rb_sys_fail("recvmsg(2)");
+ while ((int)BLOCKING_REGION_FD(recvmsg_blocking, &arg) == -1) {
+ if (!rb_io_wait_readable(arg.fd))
+ rb_sys_fail("recvmsg(2)");
+ }
#if FD_PASSING_BY_MSG_CONTROL
if (arg.msg.msg_controllen < sizeof(struct cmsghdr)) {