summaryrefslogtreecommitdiff
path: root/ext/socket/ancdata.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-02-21 00:55:13 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-02-21 00:55:13 +0000
commitd691a28d914e7e5152b7dc3f47da1baaf684fbfb (patch)
tree9d7dba4c95dd0e2afe4a5623e9a522e1cf99fcb9 /ext/socket/ancdata.c
parentf404c1022c8389c20569c139f12bbace12ed82ad (diff)
socket: sendmsg/recvmsg only retries blocking on errors
* ext/socket/ancdata.c (bsock_sendmsg_internal): only retry on error (bsock_recvmsg_internal): ditto * test/socket/test_unix.rb: test above for infinite loop git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45066 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket/ancdata.c')
-rw-r--r--ext/socket/ancdata.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/ext/socket/ancdata.c b/ext/socket/ancdata.c
index 7054d65..218085d 100644
--- a/ext/socket/ancdata.c
+++ b/ext/socket/ancdata.c
@@ -1282,12 +1282,11 @@ bsock_sendmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
ss = rb_sendmsg(fptr->fd, &mh, flags);
- if (!nonblock && rb_io_wait_writable(fptr->fd)) {
- rb_io_check_closed(fptr);
- goto retry;
- }
-
if (ss == -1) {
+ if (!nonblock && rb_io_wait_writable(fptr->fd)) {
+ rb_io_check_closed(fptr);
+ goto retry;
+ }
if (nonblock && (errno == EWOULDBLOCK || errno == EAGAIN))
rb_readwrite_sys_fail(RB_IO_WAIT_WRITABLE, "sendmsg(2) would block");
rb_sys_fail("sendmsg(2)");
@@ -1601,12 +1600,11 @@ bsock_recvmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
ss = rb_recvmsg(fptr->fd, &mh, flags);
- if (!nonblock && rb_io_wait_readable(fptr->fd)) {
- rb_io_check_closed(fptr);
- goto retry;
- }
-
if (ss == -1) {
+ if (!nonblock && rb_io_wait_readable(fptr->fd)) {
+ rb_io_check_closed(fptr);
+ goto retry;
+ }
if (nonblock && (errno == EWOULDBLOCK || errno == EAGAIN))
rb_readwrite_sys_fail(RB_IO_WAIT_READABLE, "recvmsg(2) would block");
#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)