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

ruby-changes:27630

From: kosaki <ko1@a...>
Date: Sun, 10 Mar 2013 12:59:48 +0900 (JST)
Subject: [ruby-changes:27630] kosaki:r39682 (trunk): * thread_pthread.c (consume_communication_pipe): retry when

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

  New Revision: 39682

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

  Log:
    * thread_pthread.c (consume_communication_pipe): retry when
      read returned CCP_READ_BUFF_SIZE.

  Modified files:
    trunk/ChangeLog
    trunk/thread_pthread.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 39681)
+++ ChangeLog	(revision 39682)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Mar  3 02:42:29 2013  KOSAKI Motohiro  <kosaki.motohiro@g...>
+
+	* thread_pthread.c (consume_communication_pipe): retry when
+	  read returned CCP_READ_BUFF_SIZE.
+
 Wed Mar  6 21:31:35 2013  KOSAKI Motohiro  <kosaki.motohiro@g...>
 
 	* thread_pthread.c (timer_thread_sleep): use poll() instead of
Index: thread_pthread.c
===================================================================
--- thread_pthread.c	(revision 39681)
+++ thread_pthread.c	(revision 39682)
@@ -1186,13 +1186,20 @@ consume_communication_pipe(void) https://github.com/ruby/ruby/blob/trunk/thread_pthread.c#L1186
     static char buff[CCP_READ_BUFF_SIZE];
     ssize_t result;
 
-  retry:
-    result = read(timer_thread_pipe[0], buff, CCP_READ_BUFF_SIZE);
-    if (result < 0) {
-	switch (errno) {
-	  case EINTR: goto retry;
-	  default:
-	    rb_async_bug_errno("consume_communication_pipe: read\n", errno);
+    while (1) {
+	result = read(timer_thread_pipe[0], buff, sizeof(buff));
+	if (result == 0) {
+	    return;
+	}
+	else if (result < 0) {
+	    switch (errno) {
+	    case EINTR:
+		continue; /* retry */
+	    case EAGAIN:
+		return;
+	    default:
+		rb_async_bug_errno("consume_communication_pipe: read\n", errno);
+	    }
 	}
     }
 }

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

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