summaryrefslogtreecommitdiff
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
commite8c17f1a59e298b336728de8f6b3497c9b13885a (patch)
tree4ac6b3e9f582c3f1e805644d3ae849ff2496a4e2 /thread.c
parent4bfd1339935961b957e08634b623c5080458f678 (diff)
* thread.c (terminate_atfork_i): all mutex locks by other threads
have been abandoned at fork. git-svn-id: svn+ssh://ci.ruby-lang.org/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 5ea1982378..5caf1da4ff 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)
{