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

ruby-changes:22376

From: naruse <ko1@a...>
Date: Fri, 3 Feb 2012 10:12:27 +0900 (JST)
Subject: [ruby-changes:22376] naruse:r34425 (ruby_1_9_3): merge revision(s) r34038,34099:

naruse	2012-02-03 10:11:37 +0900 (Fri, 03 Feb 2012)

  New Revision: 34425

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

  Log:
    merge revision(s) r34038,34099:
    
    * thread_pthread.c (ubf_select): call rb_thread_wakeup_timer_thread()
      only when it is not timer_thread. [Bug #5757] [ruby-dev:44985]
      patched by Tomoyuki Chikanaga.
    
    * thread_pthread.c (ping_signal_thread_list): remove return value.
    
    * thread_pthread.c (check_signal_thread_list): add a new function to
      check if signal thread list is empty.
    
    * thread_pthread.c (thread_timer): check signal thread list after
      timer_thread_function(). main thread might be added into signal thread
      list during timer_thread_function().

  Modified files:
    branches/ruby_1_9_3/ChangeLog
    branches/ruby_1_9_3/test/ruby/test_thread.rb
    branches/ruby_1_9_3/thread_pthread.c
    branches/ruby_1_9_3/version.h

Index: ruby_1_9_3/ChangeLog
===================================================================
--- ruby_1_9_3/ChangeLog	(revision 34424)
+++ ruby_1_9_3/ChangeLog	(revision 34425)
@@ -1,3 +1,18 @@
+Fri Feb  3 10:10:02 2012  CHIKANAGA Tomoyuki  <nagachika00@g...>
+
+	* thread_pthread.c (ping_signal_thread_list): remove return value.
+	* thread_pthread.c (check_signal_thread_list): add a new function to
+	  check if signal thread list is empty.
+	* thread_pthread.c (thread_timer): check signal thread list after
+	  timer_thread_function(). main thread might be added into signal thread
+	  list during timer_thread_function().
+
+Fri Feb  3 10:10:02 2012  NARUSE, Yui  <naruse@r...>
+
+	* thread_pthread.c (ubf_select): call rb_thread_wakeup_timer_thread()
+	  only when it is not timer_thread. [Bug #5757] [ruby-dev:44985]
+	  patched by Tomoyuki Chikanaga.
+
 Wed Feb  1 09:50:10 2012  Nobuyoshi Nakada  <nobu@r...>
 
 	* doc/re.rdoc (Repetition): fix typo.  reported by Ori Avtalion
Index: ruby_1_9_3/thread_pthread.c
===================================================================
--- ruby_1_9_3/thread_pthread.c	(revision 34424)
+++ ruby_1_9_3/thread_pthread.c	(revision 34425)
@@ -35,6 +35,7 @@
 static void native_cond_wait(rb_thread_cond_t *cond, pthread_mutex_t *mutex);
 static void native_cond_initialize(rb_thread_cond_t *cond, int flags);
 static void native_cond_destroy(rb_thread_cond_t *cond);
+static pthread_t timer_thread_id;
 
 #define RB_CONDATTR_CLOCK_MONOTONIC 1
 
@@ -1009,11 +1010,12 @@
 {
     rb_thread_t *th = (rb_thread_t *)ptr;
     add_signal_thread_list(th);
-    rb_thread_wakeup_timer_thread(); /* activate timer thread */
+    if (pthread_self() != timer_thread_id)
+	rb_thread_wakeup_timer_thread(); /* activate timer thread */
     ubf_select_each(th);
 }
 
-static int
+static void
 ping_signal_thread_list(void) {
     if (signal_thread_list_anchor.next) {
 	FGLOCK(&signal_thread_list_lock, {
@@ -1025,20 +1027,25 @@
 		list = list->next;
 	    }
 	});
+    }
+}
+
+static int
+check_signal_thread_list(void)
+{
+    if (signal_thread_list_anchor.next)
 	return 1;
-    }
-    else {
+    else
 	return 0;
-    }
 }
 #else /* USE_SIGNAL_THREAD_LIST */
 static void add_signal_thread_list(rb_thread_t *th) { }
 static void remove_signal_thread_list(rb_thread_t *th) { }
 #define ubf_select 0
-static int ping_signal_thread_list(void) { return 0; }
+static void ping_signal_thread_list(void) { return; }
+static int check_signal_thread_list(void) { return 0; }
 #endif /* USE_SIGNAL_THREAD_LIST */
 
-static pthread_t timer_thread_id;
 static int timer_thread_pipe[2] = {-1, -1};
 static int timer_thread_pipe_owner_process;
 
@@ -1126,8 +1133,9 @@
 	int need_polling;
 
 	/* timer function */
-	need_polling = ping_signal_thread_list();
+	ping_signal_thread_list();
 	timer_thread_function(0);
+	need_polling = check_signal_thread_list();
 
 	if (TT_DEBUG) WRITE_CONST(2, "tick\n");
 
Index: ruby_1_9_3/version.h
===================================================================
--- ruby_1_9_3/version.h	(revision 34424)
+++ ruby_1_9_3/version.h	(revision 34425)
@@ -1,10 +1,10 @@
 #define RUBY_VERSION "1.9.3"
-#define RUBY_PATCHLEVEL 29
+#define RUBY_PATCHLEVEL 30
 
-#define RUBY_RELEASE_DATE "2012-02-01"
+#define RUBY_RELEASE_DATE "2012-02-03"
 #define RUBY_RELEASE_YEAR 2012
 #define RUBY_RELEASE_MONTH 2
-#define RUBY_RELEASE_DAY 1
+#define RUBY_RELEASE_DAY 3
 
 #include "ruby/version.h"
 
Index: ruby_1_9_3/test/ruby/test_thread.rb
===================================================================
--- ruby_1_9_3/test/ruby/test_thread.rb	(revision 34424)
+++ ruby_1_9_3/test/ruby/test_thread.rb	(revision 34425)
@@ -685,4 +685,19 @@
     t.join
     assert_equal(nil, t.backtrace)
   end
+
+  def test_thread_timer_and_interrupt
+    bug5757 = '[ruby-dev:44985]'
+    t0 = Time.now.to_f
+    pid = spawn(EnvUtil.rubybin, '-e', '$stdin.read')
+    sleep 1;
+    Process.kill(:SIGQUIT, pid)
+    Process.wait(pid)
+    s = $?
+    assert_equal([false, true, false],
+                 [s.exited?, s.signaled?, s.stopped?],
+                 "[s.exited?, s.signaled?, s.stopped?]")
+    t1 = Time.now.to_f
+    assert_in_delta(t1 - t0, 1, 1)
+  end
 end

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

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