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

ruby-changes:27627

From: kosaki <ko1@a...>
Date: Sun, 10 Mar 2013 12:59:17 +0900 (JST)
Subject: [ruby-changes:27627] kosaki:r39679 (trunk): * thread_pthread.c (set_nonblock): new helper function for set O_NONBLOCK.

kosaki	2013-03-10 12:59:07 +0900 (Sun, 10 Mar 2013)

  New Revision: 39679

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

  Log:
    * thread_pthread.c (set_nonblock): new helper function for set O_NONBLOCK.
    * thread_pthread.c (rb_thread_create_timer_thread): set O_NONBLOCK
      to timer_thread_pipe[0] too.

  Modified files:
    trunk/ChangeLog
    trunk/thread_pthread.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 39678)
+++ ChangeLog	(revision 39679)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Mar  3 02:30:36 2013  KOSAKI Motohiro  <kosaki.motohiro@g...>
+
+	* thread_pthread.c (set_nonblock): new helper function for set
+	  O_NONBLOCK.
+	* thread_pthread.c (rb_thread_create_timer_thread): set O_NONBLOCK
+	  to timer_thread_pipe[0] too.
+
 Sun Mar 10 09:12:51 2013  Tadayoshi Funaba  <tadf@d...>
 
 	* complex.c: described syntax of string form.
Index: thread_pthread.c
===================================================================
--- thread_pthread.c	(revision 39678)
+++ thread_pthread.c	(revision 39679)
@@ -1313,6 +1313,23 @@ thread_timer(void *p) https://github.com/ruby/ruby/blob/trunk/thread_pthread.c#L1313
 }
 
 static void
+set_nonblock(int fd)
+{
+#if defined(HAVE_FCNTL) && defined(F_GETFL) && defined(F_SETFL) && defined(O_NONBLOCK)
+    int oflags;
+    int err;
+
+    oflags = fcntl(fd, F_GETFL);
+    if (oflags == -1)
+	rb_sys_fail(0);
+    oflags |= O_NONBLOCK;
+    err = fcntl(fd, F_SETFL, oflags);
+    if (err == -1)
+	rb_sys_fail(0);
+#endif
+}
+
+static void
 rb_thread_create_timer_thread(void)
 {
     if (!timer_thread_id) {
@@ -1355,20 +1372,8 @@ rb_thread_create_timer_thread(void) https://github.com/ruby/ruby/blob/trunk/thread_pthread.c#L1372
 	    }
             rb_update_max_fd(timer_thread_pipe[0]);
             rb_update_max_fd(timer_thread_pipe[1]);
-# if defined(HAVE_FCNTL) && defined(F_GETFL) && defined(F_SETFL) && defined(O_NONBLOCK)
-	    {
-		int oflags;
-		int err;
-
-		oflags = fcntl(timer_thread_pipe[1], F_GETFL);
-		if (oflags == -1)
-		    rb_sys_fail(0);
-		oflags |= O_NONBLOCK;
-		err = fcntl(timer_thread_pipe[1], F_SETFL, oflags);
-		if (err == -1)
-		    rb_sys_fail(0);
-	    }
-# endif /* defined(HAVE_FCNTL) && defined(F_GETFL) && defined(F_SETFL) */
+	    set_nonblock(timer_thread_pipe[0]);
+	    set_nonblock(timer_thread_pipe[1]);
 
 	    /* validate pipe on this process */
 	    timer_thread_pipe_owner_process = getpid();

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

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