From: Eric Wong <e@80x24.org>
To: spew@80x24.org
Subject: [PATCH] ext/socket/init.c (rsock_s_recvfrom_nonblock): avoid redundant fcntl
Date: Tue, 12 May 2015 00:23:45 +0000 [thread overview]
Message-ID: <1431390225-2406-1-git-send-email-e@80x24.org> (raw)
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
reply other threads:[~2015-05-12 0:23 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1431390225-2406-1-git-send-email-e@80x24.org \
--to=e@80x24.org \
--cc=spew@80x24.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).