summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-01-14 10:02:51 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-01-14 10:02:51 +0000
commit5360e77db8aa0e40c7c79cee74f91634eefa8576 (patch)
tree86477a2fa45b184bf486273cb80503cdebd1c59b /thread.c
parent4b8de30bc5c69b636851559689922aa522e0f472 (diff)
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15044 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/thread.c b/thread.c
index e5b79b7330..7326c59347 100644
--- a/thread.c
+++ b/thread.c
@@ -1955,7 +1955,18 @@ rb_thread_start_timer_thread(void)
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 @@ rb_thread_atfork(void)
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);
}