From 079545cd8c7a2c0da45977bec7d88aa3d1232820 Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 28 Nov 2010 05:46:32 +0000 Subject: [PATCH] * thread_pthread.c (gvl_reinit): register atfork hander only in the parent process, to get rid of dead lock. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29957 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ thread_pthread.c | 12 ++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index a8fe3c5fc6..cb11c2c985 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun Nov 28 14:46:24 2010 Nobuyoshi Nakada + + * thread_pthread.c (gvl_reinit): register atfork hander only in + the parent process, to get rid of dead lock. + Sun Nov 28 12:23:57 2010 Koichi Sasada * thread.c, vm_core.h: make gvl_acquire/release/init/destruct diff --git a/thread_pthread.c b/thread_pthread.c index 2207fde0e3..9966943f8e 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -132,22 +132,26 @@ gvl_atfork(rb_vm_t *vm) #endif } -static void gvl_init(rb_vm_t *vm); +static void gvl_reinit(rb_vm_t *vm); static void gvl_atfork_child(void) { - gvl_init(GET_VM()); + gvl_reinit(GET_VM()); } static void gvl_init(rb_vm_t *vm) { - int r; if (GVL_DEBUG) fprintf(stderr, "gvl init\n"); - native_mutex_initialize(&vm->gvl.lock); native_atfork(0, 0, gvl_atfork_child); + gvl_reinit(vm); +} +static void +gvl_reinit(rb_vm_t *vm) +{ + native_mutex_initialize(&vm->gvl.lock); vm->gvl.waiting_threads = 0; vm->gvl.waiting_last_thread = 0; vm->gvl.waiting = 0;