* [PATCH] ext/socket/init.c (rsock_s_recvfrom_nonblock): avoid redundant fcntl
@ 2015-05-12 0:23 Eric Wong
0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2015-05-12 0:23 UTC (permalink / raw)
To: spew
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.
---
ext/socket/init.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/ext/socket/init.c b/ext/socket/init.c
index 0bafec4..ac39d85 100644
--- a/ext/socket/init.c
+++ b/ext/socket/init.c
@@ -211,7 +211,11 @@ rsock_s_recvfrom_nonblock(VALUE sock, int argc, VALUE *argv, enum sock_recv_type
str = rb_tainted_str_new(0, buflen);
rb_io_check_closed(fptr);
+
+#ifndef MSG_DONTWAIT
rb_io_set_nonblock(fptr);
+#endif
+
len0 = alen;
slen = recvfrom(fd, RSTRING_PTR(str), buflen, flags, &buf.addr, &alen);
if (slen != -1 && len0 < alen)
--
EW
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2015-05-12 0:23 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-12 0:23 [PATCH] ext/socket/init.c (rsock_s_recvfrom_nonblock): avoid redundant fcntl Eric Wong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).