1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
nobu 2009-11-18 08:48:24 +00:00
parent 4bfd133993
commit e8c17f1a59
2 changed files with 23 additions and 0 deletions

View file

@ -1,3 +1,8 @@
Wed Nov 18 17:48:22 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* thread.c (terminate_atfork_i): all mutex locks by other threads
have been abandoned at fork.
Wed Nov 18 15:27:20 2009 NAKAMURA Usaku <usa@ruby-lang.org>
* file.c (file_path_convert): delay getting filesystem encoding

View file

@ -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)
{