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

ruby-changes:19879

From: kosaki <ko1@a...>
Date: Sun, 5 Jun 2011 21:48:30 +0900 (JST)
Subject: [ruby-changes:19879] kosaki:r31926 (trunk): * thread_pthread.c (thread_timer): add to care a spurious wakeup.

kosaki	2011-06-05 21:48:23 +0900 (Sun, 05 Jun 2011)

  New Revision: 31926

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

  Log:
    * thread_pthread.c (thread_timer): add to care a spurious wakeup.
      When native_cond_timedwait() return 0 by spurious wakeup, we
      don't have to neither 1) call timer_thread_function and 2)
      exit the timer thread.

  Modified files:
    trunk/ChangeLog
    trunk/thread_pthread.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 31925)
+++ ChangeLog	(revision 31926)
@@ -1,3 +1,10 @@
+Sun Jun  5 21:38:51 2011  KOSAKI Motohiro  <kosaki.motohiro@g...>
+
+	* thread_pthread.c (thread_timer): add to care a spurious wakeup.
+	  When native_cond_timedwait() return 0 by spurious wakeup, we
+	  don't have to neither 1) call timer_thread_function and 2)
+	  exit the timer thread.
+
 Sun Jun  5 17:50:01 2011  Tadayoshi Funaba  <tadf@d...>
 
 	* ext/date/date_core.c (m_real_cwyear): new.  derived from m_cwyear.
Index: thread_pthread.c
===================================================================
--- thread_pthread.c	(revision 31925)
+++ thread_pthread.c	(revision 31926)
@@ -993,27 +993,33 @@
 thread_timer(void *dummy)
 {
     struct timespec timeout_10ms;
+    struct timespec timeout;
 
     timeout_10ms.tv_sec = 0;
     timeout_10ms.tv_nsec = 10 * 1000 * 1000;
 
     native_mutex_lock(&timer_thread_lock);
     native_cond_broadcast(&timer_thread_cond);
+    timeout = native_cond_timeout(&timer_thread_cond, timeout_10ms);
+
     while (system_working > 0) {
 	int err;
-	struct timespec timeout;
 
-	timeout = native_cond_timeout(&timer_thread_cond, timeout_10ms);
 	err = native_cond_timedwait(&timer_thread_cond, &timer_thread_lock,
 				    &timeout);
-	if (err == ETIMEDOUT);
-	else if (err == 0) {
-	    if (rb_signal_buff_size() == 0) break;
+	if (err == 0) {
+	    /*
+	     * Spurious wakeup or native_stop_timer_thread() was called.
+	     * We need to recheck a system_working state.
+	     */
 	}
-	else rb_bug_errno("thread_timer/timedwait", err);
-
-	ping_signal_thread_list();
-	timer_thread_function(dummy);
+	else if (err == ETIMEDOUT) {
+	    ping_signal_thread_list();
+	    timer_thread_function(dummy);
+	    timeout = native_cond_timeout(&timer_thread_cond, timeout_10ms);
+	}
+	else
+	    rb_bug_errno("thread_timer/timedwait", err);
     }
     native_mutex_unlock(&timer_thread_lock);
     return NULL;

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

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