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

ruby-changes:14031

From: nobu <ko1@a...>
Date: Wed, 18 Nov 2009 18:25:48 +0900 (JST)
Subject: [ruby-changes:14031] Ruby:r25842 (trunk): * thread.c (rb_thread_atfork_internal): reinitialize global lock

nobu	2009-11-18 18:25:11 +0900 (Wed, 18 Nov 2009)

  New Revision: 25842

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

  Log:
    * thread.c (rb_thread_atfork_internal): reinitialize global lock
      at fork to get rid of deadlock.  based on the patch from Hongli
      Lai in [ruby-core:26783].  [ruby-core:26361]

  Modified files:
    trunk/ChangeLog
    trunk/bootstraptest/test_thread.rb
    trunk/thread.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 25841)
+++ ChangeLog	(revision 25842)
@@ -1,3 +1,9 @@
+Wed Nov 18 18:25:09 2009  Nobuyoshi Nakada  <nobu@r...>
+
+	* thread.c (rb_thread_atfork_internal): reinitialize global lock
+	  at fork to get rid of deadlock.  based on the patch from Hongli
+	  Lai in [ruby-core:26783].  [ruby-core:26361]
+
 Wed Nov 18 17:48:22 2009  Nobuyoshi Nakada  <nobu@r...>
 
 	* thread.c (terminate_atfork_i): all mutex locks by other threads
Index: bootstraptest/test_thread.rb
===================================================================
--- bootstraptest/test_thread.rb	(revision 25841)
+++ bootstraptest/test_thread.rb	(revision 25842)
@@ -408,3 +408,22 @@
   require "./zzz.rb"
   $result
 }
+
+assert_finish 3, %q{
+  require 'thread'
+
+  lock = Mutex.new
+  cond = ConditionVariable.new
+  t = Thread.new do
+    lock.synchronize do
+      cond.wait(lock)
+    end
+  end
+
+  pid = fork do
+    # Child
+    STDOUT.write "This is the child process.\n"
+    STDOUT.write "Child process exiting.\n"
+  end
+  Process.waitpid(pid)
+}, '[ruby-core:26361]'
Index: thread.c
===================================================================
--- thread.c	(revision 25841)
+++ thread.c	(revision 25842)
@@ -2710,6 +2710,7 @@
     VALUE thval = th->self;
     vm->main_thread = th;
 
+    native_mutex_reinitialize_atfork(&th->vm->global_vm_lock);
     st_foreach(vm->living_threads, atfork, (st_data_t)th);
     st_clear(vm->living_threads);
     st_insert(vm->living_threads, thval, (st_data_t)th->thread_id);

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

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