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

ruby-changes:14010

From: shyouhei <ko1@a...>
Date: Tue, 17 Nov 2009 16:38:14 +0900 (JST)
Subject: [ruby-changes:14010] Ruby:r25819 (ruby_1_8_7): merge revision(s) 24958,24979:

shyouhei	2009-11-17 16:32:15 +0900 (Tue, 17 Nov 2009)

  New Revision: 25819

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

  Log:
    merge revision(s) 24958,24979:
    * eval.c (rb_thread_start_timer): start to catch SIGVTALRM together
      with timer thread.   [ruby-core:25606]
    * eval.c (rb_thread_atfork): stop timer thread.
    * eval.c (rb_thread_start_0, rb_thread_start_1): should call star
      timer after added new thread to thread list.  [ruby-core:25613]

  Modified files:
    branches/ruby_1_8_7/ChangeLog
    branches/ruby_1_8_7/eval.c
    branches/ruby_1_8_7/test/ruby/test_signal.rb
    branches/ruby_1_8_7/version.h

Index: ruby_1_8_7/ChangeLog
===================================================================
--- ruby_1_8_7/ChangeLog	(revision 25818)
+++ ruby_1_8_7/ChangeLog	(revision 25819)
@@ -1,3 +1,15 @@
+Tue Nov 17 16:22:22 2009  Nobuyoshi Nakada  <nobu@r...>
+
+	* eval.c (rb_thread_start_0, rb_thread_start_1): should call star
+	  timer after added new thread to thread list.  [ruby-core:25613]
+
+Tue Nov 17 16:22:22 2009  Nobuyoshi Nakada  <nobu@r...>
+
+	* eval.c (rb_thread_start_timer): start to catch SIGVTALRM together
+	  with timer thread.   [ruby-core:25606]
+
+	* eval.c (rb_thread_atfork): stop timer thread.
+
 Tue Nov 17 16:04:02 2009  Marc-Andre Lafortune  <ruby-core@m...>
 
 	* lib/cgi/cookie.rb (value): Keep CGI::Cookie#value in sync with the
Index: ruby_1_8_7/version.h
===================================================================
--- ruby_1_8_7/version.h	(revision 25818)
+++ ruby_1_8_7/version.h	(revision 25819)
@@ -2,7 +2,7 @@
 #define RUBY_RELEASE_DATE "2009-11-17"
 #define RUBY_VERSION_CODE 187
 #define RUBY_RELEASE_CODE 20091117
-#define RUBY_PATCHLEVEL 209
+#define RUBY_PATCHLEVEL 210
 
 #define RUBY_VERSION_MAJOR 1
 #define RUBY_VERSION_MINOR 8
Index: ruby_1_8_7/test/ruby/test_signal.rb
===================================================================
--- ruby_1_8_7/test/ruby/test_signal.rb	(revision 25818)
+++ ruby_1_8_7/test/ruby/test_signal.rb	(revision 25819)
@@ -65,4 +65,11 @@
       w0.close
     end
   end
+
+  def test_child_vtalrm
+    return unless have_fork?	# snip this test
+    pid = fork {100_000.times{ 1+1 }}
+    pid, status = Process.wait2(pid)
+    assert_equal(false, status.signaled?, '[ruby-core:25606]')
+  end
 end
Index: ruby_1_8_7/eval.c
===================================================================
--- ruby_1_8_7/eval.c	(revision 25818)
+++ ruby_1_8_7/eval.c	(revision 25819)
@@ -12244,6 +12244,12 @@
 
 static int thread_init;
 
+#if defined(POSIX_SIGNAL)
+#define CATCH_VTALRM() posix_signal(SIGVTALRM, catch_timer)
+#else
+#define CATCH_VTALRM() signal(SIGVTALRM, catch_timer)
+#endif
+
 #if defined(_THREAD_SAFE)
 static void
 catch_timer(sig)
@@ -12327,6 +12333,8 @@
     static pthread_cond_t start = PTHREAD_COND_INITIALIZER;
 
     if (thread_init) return;
+    if (rb_thread_alone()) return;
+    CATCH_VTALRM();
     args[0] = &time_thread;
     args[1] = &start;
     safe_mutex_lock(&time_thread.lock);
@@ -12368,6 +12376,8 @@
     struct itimerval tval;
 
     if (thread_init) return;
+    if (rb_thread_alone()) return;
+    CATCH_VTALRM();
     tval.it_interval.tv_sec = 0;
     tval.it_interval.tv_usec = 10000;
     tval.it_value = tval.it_interval;
@@ -12391,6 +12401,14 @@
 int rb_thread_tick = THREAD_TICK;
 #endif
 
+#if defined(HAVE_SETITIMER) || defined(_THREAD_SAFE)
+#define START_TIMER() (thread_init ? (void)0 : rb_thread_start_timer())
+#define STOP_TIMER() (rb_thread_stop_timer())
+#else
+#define START_TIMER() ((void)0)
+#define STOP_TIMER() ((void)0)
+#endif
+
 static VALUE
 rb_thread_start_0(fn, arg, th)
     VALUE (*fn)();
@@ -12408,18 +12426,6 @@
 		 "can't start a new thread (frozen ThreadGroup)");
     }
 
-    if (!thread_init) {
-#if defined(HAVE_SETITIMER) || defined(_THREAD_SAFE)
-#if defined(POSIX_SIGNAL)
-	posix_signal(SIGVTALRM, catch_timer);
-#else
-	signal(SIGVTALRM, catch_timer);
-#endif
-
-	rb_thread_start_timer();
-#endif
-    }
-
     if (THREAD_SAVE_CONTEXT(curr_thread)) {
 	return thread;
     }
@@ -12442,6 +12448,7 @@
 	th->priority = curr_thread->priority;
 	th->thgroup = curr_thread->thgroup;
     }
+    START_TIMER();
 
     PUSH_TAG(PROT_THREAD);
     if ((state = EXEC_TAG()) == 0) {
@@ -13167,6 +13174,7 @@
     main_thread = curr_thread;
     curr_thread->next = curr_thread;
     curr_thread->prev = curr_thread;
+    STOP_TIMER();
 }
 
 

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

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