[前][次][番号順一覧][スレッド一覧]

ruby-changes:19199

From: kosaki <ko1@a...>
Date: Mon, 4 Apr 2011 22:11:20 +0900 (JST)
Subject: [ruby-changes:19199] Ruby:r31238 (trunk): * ext/io/nonblock/nonblock.c (io_nonblock_set): Avoid F_SETFL if

kosaki	2011-04-04 22:11:14 +0900 (Mon, 04 Apr 2011)

  New Revision: 31238

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=31238

  Log:
    * ext/io/nonblock/nonblock.c (io_nonblock_set): Avoid F_SETFL if
      we're not changing the O_NONBLOCK bit. F_SETFL is an expensive
      operation since it needs to affect all processes with the same
      file object.
      The patch is written by Eric Wong. [ruby-core:35556]

  Modified files:
    trunk/ChangeLog
    trunk/ext/io/nonblock/nonblock.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 31237)
+++ ChangeLog	(revision 31238)
@@ -1,3 +1,11 @@
+Mon Apr  4 22:02:16 2011  KOSAKI Motohiro  <kosaki.motohiro@g...>
+
+	* ext/io/nonblock/nonblock.c (io_nonblock_set): Avoid F_SETFL if
+	  we're not changing the O_NONBLOCK bit. F_SETFL is an expensive
+	  operation since it needs to affect all processes with the same
+	  file object.
+	  The patch is written by Eric Wong. [ruby-core:35556]
+
 Mon Apr  4 21:41:26 2011  KOSAKI Motohiro  <kosaki.motohiro@g...>
 
 	* io.c (rb_io_syswrite): While local FS writes are usually
Index: ext/io/nonblock/nonblock.c
===================================================================
--- ext/io/nonblock/nonblock.c	(revision 31237)
+++ ext/io/nonblock/nonblock.c	(revision 31238)
@@ -47,10 +47,16 @@
 static void
 io_nonblock_set(int fd, int f, int nb)
 {
-    if (nb)
+    if (nb) {
+	if ((f & O_NONBLOCK) != 0)
+	    return;
 	f |= O_NONBLOCK;
-    else
+    }
+    else {
+	if ((f & O_NONBLOCK) == 0)
+	    return;
 	f &= ~O_NONBLOCK;
+    }
     if (fcntl(fd, F_SETFL, f) == -1)
 	rb_sys_fail(0);
 }

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]