ruby-changes:3555
From: ko1@a...
Date: Mon, 14 Jan 2008 19:03:05 +0900 (JST)
Subject: [ruby-changes:3555] ko1 - Ruby:r15044 (trunk): * thread.c: clear thread structure.
ko1 2008-01-14 19:02:51 +0900 (Mon, 14 Jan 2008)
New Revision: 15044
Modified files:
trunk/ChangeLog
trunk/bootstraptest/test_thread.rb
trunk/thread.c
Log:
* thread.c: clear thread structure.
(TODO: survey that child process should clear mutex or not).
* bootstraptest/test_knownbug.rb, test_thread.rb: move a fixed test.
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=15044&r2=15043&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/thread.c?r1=15044&r2=15043&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/bootstraptest/test_thread.rb?r1=15044&r2=15043&diff_format=u
Index: ChangeLog
===================================================================
--- ChangeLog (revision 15043)
+++ ChangeLog (revision 15044)
@@ -1,3 +1,10 @@
+Mon Jan 14 18:53:58 2008 Koichi Sasada <ko1@a...>
+
+ * thread.c: clear thread structure.
+ (TODO: survey that child process should clear mutex or not).
+
+ * bootstraptest/test_knownbug.rb, test_thread.rb: move a fixed test.
+
Mon Jan 14 18:43:38 2008 Koichi Sasada <ko1@a...>
* bootstraptest/runner.rb: add "flunk" method.
Index: bootstraptest/test_thread.rb
===================================================================
--- bootstraptest/test_thread.rb (revision 15043)
+++ bootstraptest/test_thread.rb (revision 15044)
@@ -193,3 +193,11 @@
100
end
}, '[ruby-dev:31371]'
+assert_equal 'true', %{
+ t = Thread.new { loop {} }
+ pid = fork {
+ exit t.status != "run"
+ }
+ Process.wait pid
+ $?.success?
+}
Index: thread.c
===================================================================
--- thread.c (revision 15043)
+++ thread.c (revision 15044)
@@ -1955,8 +1955,19 @@
rb_thread_create_timer_thread();
}
-/***/
+static int
+terminate_atfork_i(st_data_t key, st_data_t val, rb_thread_t *current_th)
+{
+ VALUE thval = key;
+ rb_thread_t *th;
+ GetThreadPtr(thval, th);
+ if (th != current_th) {
+ thread_cleanup_func(th);
+ }
+ return ST_CONTINUE;
+}
+
void
rb_thread_atfork(void)
{
@@ -1965,6 +1976,7 @@
VALUE thval = th->self;
vm->main_thread = th;
+ st_foreach(vm->living_threads, terminate_atfork_i, (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/