sleepy_penguin RubyGem user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
From: Eric Wong <normalperson@yhbt.net>
To: sleepy.penguin@librelist.org
Subject: [sleepy.penguin] [PATCH] util: comment explaining non-use of FIONBIO
Date: Wed, 3 Apr 2013 00:30:41 +0000	[thread overview]
Message-ID: <20130403003041.GA23982@dcvr.yhbt.net> (raw)
In-Reply-To: <20130403003041.GA23982@dcvr.yhbt.net>

I was about to change this to the FIONBIO here myself before
I realized we do not frequently _change_ file flags.
---
 ext/sleepy_penguin/util.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/ext/sleepy_penguin/util.c b/ext/sleepy_penguin/util.c
index 301cc92..5cf84bf 100644
--- a/ext/sleepy_penguin/util.c
+++ b/ext/sleepy_penguin/util.c
@@ -123,6 +123,13 @@ void rb_sp_set_nonblock(int fd)
 		rb_sys_fail("fcntl(F_GETFL)");
 	if ((flags & O_NONBLOCK) == O_NONBLOCK)
 		return;
+	/*
+	 * Note: while this is Linux-only and we could safely rely on
+	 * ioctl(FIONBIO), needing F_SETFL is an uncommon path, and
+	 * F_GETFL is lockless.  ioctl(FIONBIO) always acquires a spin
+	 * lock, so it's more expensive even if we do not need to change
+	 * anything.
+	 */
 	flags = fcntl(fd, F_SETFL, flags | O_NONBLOCK);
 	if (flags == -1)
 		rb_sys_fail("fcntl(F_SETFL)");
-- 
1.8.2.279.g631bc94



           reply	other threads:[~2013-04-03  0:30 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <20130403003041.GA23982@dcvr.yhbt.net>]

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

  List information: https://yhbt.net/sleepy_penguin/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130403003041.GA23982@dcvr.yhbt.net \
    --to=normalperson@yhbt.net \
    --cc=sleepy.penguin@librelist.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.
Code repositories for project(s) associated with this public inbox

	https://yhbt.net/sleepy_penguin.git/

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).