ruby-changes:14030
From: nobu <ko1@a...>
Date: Wed, 18 Nov 2009 17:49:41 +0900 (JST)
Subject: [ruby-changes:14030] Ruby:r25841 (trunk): * thread.c (terminate_atfork_i): all mutex locks by other threads
nobu 2009-11-18 17:48:24 +0900 (Wed, 18 Nov 2009) New Revision: 25841 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=25841 Log: * thread.c (terminate_atfork_i): all mutex locks by other threads have been abandoned at fork. Modified files: trunk/ChangeLog trunk/thread.c Index: ChangeLog =================================================================== --- ChangeLog (revision 25840) +++ ChangeLog (revision 25841) @@ -1,3 +1,8 @@ +Wed Nov 18 17:48:22 2009 Nobuyoshi Nakada <nobu@r...> + + * 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@r...> * file.c (file_path_convert): delay getting filesystem encoding Index: thread.c =================================================================== --- thread.c (revision 25840) +++ thread.c (revision 25841) @@ -323,6 +323,7 @@ } 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 @@ 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 @@ } } +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) { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/