aboutsummaryrefslogtreecommitdiffstats
path: root/ext/socket/ancdata.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-29 02:24:18 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-29 02:24:18 +0000
commit9dd4ccf16994ff6228ab9afb33f2df4556212a28 (patch)
tree77defb6e5c5cc03585e032b243a0c8513fd671eb /ext/socket/ancdata.c
parent05ab1d67b3ffd23750304c00486e09dcd4b8e787 (diff)
downloadruby-9dd4ccf16994ff6228ab9afb33f2df4556212a28.tar.gz
socket: avoid redundant fcntl on Linux
* ext/socket/ancdata.c (bsock_sendmsg_internal, bsock_recvmsg_internal): avoid redundant fcntl on Linux [ruby-core:69154] [Feature #11145] * ext/socket/init.c (rsock_s_recvfrom_nonblock): ditto * ext/socket/rubysocket.h (MSG_DONTWAIT_RELIABLE): new macro MSG_DONTWAIT is enough to force non-blocking I/O under Linux, so avoid changing the state of a socket. This will allow certain threads to do a non-destructive non-blocking "peek" while others block (without relying on an extra ppoll syscall). We shall be conservative about enabling this feature since some OSes may have incomplete support for MSG_DONTWAIT. I shall defer to a FreeBSD expert to enable that for FreeBSD. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50666 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket/ancdata.c')
-rw-r--r--ext/socket/ancdata.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/ext/socket/ancdata.c b/ext/socket/ancdata.c
index 3eaed1cb49..0a94149b08 100644
--- a/ext/socket/ancdata.c
+++ b/ext/socket/ancdata.c
@@ -1277,7 +1277,7 @@ bsock_sendmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
#endif
rb_io_check_closed(fptr);
- if (nonblock)
+ if (nonblock && !MSG_DONTWAIT_RELIABLE)
rb_io_set_nonblock(fptr);
ss = rb_sendmsg(fptr->fd, &mh, flags);
@@ -1595,7 +1595,7 @@ bsock_recvmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
flags |= MSG_PEEK;
rb_io_check_closed(fptr);
- if (nonblock)
+ if (nonblock && !MSG_DONTWAIT_RELIABLE)
rb_io_set_nonblock(fptr);
ss = rb_recvmsg(fptr->fd, &mh, flags);