mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* thread.c (rb_thread_atfork_internal): reinitialize global lock
at fork to get rid of deadlock. based on the patch from Hongli Lai in [ruby-core:26783]. [ruby-core:26361] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25842 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e8c17f1a59
commit
748fe216c2
3 changed files with 26 additions and 0 deletions
|
@ -1,3 +1,9 @@
|
|||
Wed Nov 18 18:25:09 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* thread.c (rb_thread_atfork_internal): reinitialize global lock
|
||||
at fork to get rid of deadlock. based on the patch from Hongli
|
||||
Lai in [ruby-core:26783]. [ruby-core:26361]
|
||||
|
||||
Wed Nov 18 17:48:22 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* thread.c (terminate_atfork_i): all mutex locks by other threads
|
||||
|
|
|
@ -408,3 +408,22 @@ assert_equal 'ok', %{
|
|||
require "./zzz.rb"
|
||||
$result
|
||||
}
|
||||
|
||||
assert_finish 3, %q{
|
||||
require 'thread'
|
||||
|
||||
lock = Mutex.new
|
||||
cond = ConditionVariable.new
|
||||
t = Thread.new do
|
||||
lock.synchronize do
|
||||
cond.wait(lock)
|
||||
end
|
||||
end
|
||||
|
||||
pid = fork do
|
||||
# Child
|
||||
STDOUT.write "This is the child process.\n"
|
||||
STDOUT.write "Child process exiting.\n"
|
||||
end
|
||||
Process.waitpid(pid)
|
||||
}, '[ruby-core:26361]'
|
||||
|
|
1
thread.c
1
thread.c
|
@ -2710,6 +2710,7 @@ rb_thread_atfork_internal(int (*atfork)(st_data_t, st_data_t, st_data_t))
|
|||
VALUE thval = th->self;
|
||||
vm->main_thread = th;
|
||||
|
||||
native_mutex_reinitialize_atfork(&th->vm->global_vm_lock);
|
||||
st_foreach(vm->living_threads, atfork, (st_data_t)th);
|
||||
st_clear(vm->living_threads);
|
||||
st_insert(vm->living_threads, thval, (st_data_t)th->thread_id);
|
||||
|
|
Loading…
Add table
Reference in a new issue