summaryrefslogtreecommitdiffstats
path: root/thread.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-18 08:48:24 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-18 08:48:24 +0000
commit48f493bfc53c1502b270b79a03ec36cfa789b075 (patch)
tree4ac6b3e9f582c3f1e805644d3ae849ff2496a4e2 /thread.c
parentca0c0644b6569a251dac6b59415676749f64347b (diff)
downloadruby-48f493bfc53c1502b270b79a03ec36cfa789b075.tar.gz
ruby-48f493bfc53c1502b270b79a03ec36cfa789b075.tar.xz
ruby-48f493bfc53c1502b270b79a03ec36cfa789b075.zip
* thread.c (terminate_atfork_i): all mutex locks by other threads
have been abandoned at fork. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@25841 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/thread.c b/thread.c
index 5ea198237..5caf1da4f 100644
--- a/thread.c
+++ b/thread.c
@@ -323,6 +323,7 @@ typedef struct rb_mutex_struct
} mutex_t;
static void rb_mutex_unlock_all(mutex_t *mutex, rb_thread_t *th);
+static void rb_mutex_abandon_all(mutex_t *mutexes);
void
rb_thread_terminate_all(void)
@@ -2724,6 +2725,10 @@ terminate_atfork_i(st_data_t key, st_data_t val, st_data_t current_th)
GetThreadPtr(thval, th);
if (th != (rb_thread_t *)current_th) {
+ if (th->keeping_mutexes) {
+ rb_mutex_abandon_all(th->keeping_mutexes);
+ }
+ th->keeping_mutexes = NULL;
thread_cleanup_func(th);
}
return ST_CONTINUE;
@@ -3285,6 +3290,19 @@ rb_mutex_unlock_all(mutex_t *mutexes, rb_thread_t *th)
}
}
+static void
+rb_mutex_abandon_all(mutex_t *mutexes)
+{
+ mutex_t *mutex;
+
+ while (mutexes) {
+ mutex = mutexes;
+ mutexes = mutex->next_mutex;
+ mutex->th = 0;
+ mutex->next_mutex = 0;
+ }
+}
+
static VALUE
rb_mutex_sleep_forever(VALUE time)
{