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

ruby-changes:18249

From: kosaki <ko1@a...>
Date: Tue, 21 Dec 2010 00:19:03 +0900 (JST)
Subject: [ruby-changes:18249] Ruby:r30272 (trunk): * thread.c (thread_cleanup_func): Don't touch native threading

kosaki	2010-12-21 00:16:41 +0900 (Tue, 21 Dec 2010)

  New Revision: 30272

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

  Log:
    * thread.c (thread_cleanup_func): Don't touch native threading
              resource at fork. Sadly this is purely bandaid. We need to
              implement proper fix later. [Bug #4169] [ruby-core:33767]

  Modified files:
    trunk/ChangeLog
    trunk/thread.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 30271)
+++ ChangeLog	(revision 30272)
@@ -1,3 +1,9 @@
+Tue Dec 21 00:46:20 2010  KOSAKI Motohiro  <kosaki.motohiro@g...>
+
+	* thread.c (thread_cleanup_func): Don't touch native threading
+	  resource at fork. Sadly this is purely bandaid. We need to
+	  implement proper fix later. [Bug #4169] [ruby-core:33767]
+
 Tue Dec 21 00:22:44 2010  KOSAKI Motohiro  <kosaki.motohiro@g...>
 
 	* error.c (exit_success_p): Check status code more carefully.
Index: thread.c
===================================================================
--- thread.c	(revision 30271)
+++ thread.c	(revision 30272)
@@ -391,12 +391,21 @@
 }
 
 static void
-thread_cleanup_func(void *th_ptr)
+thread_cleanup_func(void *th_ptr, int atfork)
 {
     rb_thread_t *th = th_ptr;
 
     th->locking_mutex = Qfalse;
     thread_cleanup_func_before_exec(th_ptr);
+
+    /*
+     * Unfortunately, we can't release native threading resource at fork
+     * because libc may have unstable locking state therefore touching
+     * a threading resource may cause a deadlock.
+     */
+    if (atfork)
+	return;
+
     native_thread_destroy(th);
 }
 
@@ -525,7 +534,7 @@
 	ruby_cleanup(state);
     }
     else {
-	thread_cleanup_func(th);
+	thread_cleanup_func(th, FALSE);
 	gvl_release(th->vm);
     }
 
@@ -2780,7 +2789,7 @@
 	    rb_mutex_abandon_all(th->keeping_mutexes);
 	}
 	th->keeping_mutexes = NULL;
-	thread_cleanup_func(th);
+	thread_cleanup_func(th, TRUE);
     }
     return ST_CONTINUE;
 }

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

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