ruby-changes:20877
From: yugui <ko1@a...>
Date: Thu, 11 Aug 2011 09:40:07 +0900 (JST)
Subject: [ruby-changes:20877] yugui:r32926 (ruby_1_9_2): merges r32345 from trunk into ruby_1_9_2.
yugui 2011-08-11 09:39:16 +0900 (Thu, 11 Aug 2011) New Revision: 32926 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=32926 Log: merges r32345 from trunk into ruby_1_9_2. -- * thread.c (rb_threadptr_check_signal): only wake up main thread. * thread.c (rb_threadptr_execute_interrupts_common): check signal deliverly if it is main thread. fixes [ruby-dev:44005] [Ruby 1.9 - Bug #4950] * bootstraptest/test_fork.rb: add a test for above. * signal.c (rb_get_next_signal): skip if signal_buff is empty. (check signal_buff.size first) * vm_core.h: remove unused variable rb_thread_t::exec_signal. * thread.c (rb_thread_check_trap_pending): check rb_signal_buff_size() because rb_thread_t::exec_signal is no longer available. Modified files: branches/ruby_1_9_2/ChangeLog branches/ruby_1_9_2/bootstraptest/test_fork.rb branches/ruby_1_9_2/signal.c branches/ruby_1_9_2/thread.c branches/ruby_1_9_2/version.h branches/ruby_1_9_2/vm_core.h Index: ruby_1_9_2/ChangeLog =================================================================== --- ruby_1_9_2/ChangeLog (revision 32925) +++ ruby_1_9_2/ChangeLog (revision 32926) @@ -1,3 +1,22 @@ +Fri Jul 1 06:41:36 2011 Koichi Sasada <ko1@a...> + + * thread.c (rb_threadptr_check_signal): only wake up main thread. + + * thread.c (rb_threadptr_execute_interrupts_common): check signal + deliverly if it is main thread. + fixes [ruby-dev:44005] [Ruby 1.9 - Bug #4950] + + * bootstraptest/test_fork.rb: add a test for above. + + * signal.c (rb_get_next_signal): skip if signal_buff is empty. + (check signal_buff.size first) + + * vm_core.h: remove unused variable rb_thread_t::exec_signal. + + * thread.c (rb_thread_check_trap_pending): check + rb_signal_buff_size() because rb_thread_t::exec_signal + is no longer available. + Fri Jul 1 03:28:25 2011 Yukihiro Matsumoto <matz@r...> * class.c (Init_class_hierarchy): should name BasicObject Index: ruby_1_9_2/bootstraptest/test_fork.rb =================================================================== --- ruby_1_9_2/bootstraptest/test_fork.rb (revision 32925) +++ ruby_1_9_2/bootstraptest/test_fork.rb (revision 32926) @@ -47,3 +47,23 @@ :ok end }, '[ruby-core:28924]' + +assert_equal '[1, 2]', %q{ + a = [] + trap(:INT) { a.push(1) } + trap(:TERM) { a.push(2) } + pid = $$ + begin + fork do + sleep 0.5 + Process.kill(:INT, pid) + Process.kill(:TERM, pid) + end + + sleep 1 + a.sort + rescue NotImplementedError + [1, 2] + end +}, '[ruby-dev:44005] [Ruby 1.9 - Bug #4950]' + Index: ruby_1_9_2/vm_core.h =================================================================== --- ruby_1_9_2/vm_core.h (revision 32925) +++ ruby_1_9_2/vm_core.h (revision 32926) @@ -420,7 +420,6 @@ VALUE errinfo; VALUE thrown_errinfo; - int exec_signal; int interrupt_flag; rb_thread_lock_t interrupt_lock; Index: ruby_1_9_2/thread.c =================================================================== --- ruby_1_9_2/thread.c (revision 32925) +++ ruby_1_9_2/thread.c (revision 32926) @@ -985,7 +985,7 @@ int rb_thread_check_trap_pending(void) { - return GET_THREAD()->exec_signal != 0; + return rb_signal_buff_size() != 0; } /* This function can be called in blocking region. */ @@ -1252,25 +1252,22 @@ static void rb_threadptr_execute_interrupts_rec(rb_thread_t *th, int sched_depth) { - if (GET_VM()->main_thread == th) { - while (rb_signal_buff_size() && !th->exec_signal) native_thread_yield(); - } - if (th->raised_flag) return; while (th->interrupt_flag) { enum rb_thread_status status = th->status; int timer_interrupt = th->interrupt_flag & 0x01; int finalizer_interrupt = th->interrupt_flag & 0x04; + int sig; th->status = THREAD_RUNNABLE; th->interrupt_flag = 0; /* signal handling */ - if (th->exec_signal) { - int sig = th->exec_signal; - th->exec_signal = 0; - rb_signal_exec(th, sig); + if (th == th->vm->main_thread) { + while ((sig = rb_get_next_signal()) != 0) { + rb_signal_exec(th, sig); + } } /* exception from another thread */ @@ -2664,18 +2661,10 @@ void rb_threadptr_check_signal(rb_thread_t *mth) { - int sig; - /* mth must be main_thread */ - - if (!mth->exec_signal && (sig = rb_get_next_signal()) > 0) { - enum rb_thread_status prev_status = mth->status; - thread_debug("main_thread: %s, sig: %d\n", - thread_status_name(prev_status), sig); - mth->exec_signal = sig; - if (mth->status != THREAD_KILLED) mth->status = THREAD_RUNNABLE; + if (rb_signal_buff_size() > 0) { + /* wakeup main thread */ rb_threadptr_interrupt(mth); - mth->status = prev_status; } } Index: ruby_1_9_2/version.h =================================================================== --- ruby_1_9_2/version.h (revision 32925) +++ ruby_1_9_2/version.h (revision 32926) @@ -1,5 +1,5 @@ #define RUBY_VERSION "1.9.2" -#define RUBY_PATCHLEVEL 311 +#define RUBY_PATCHLEVEL 312 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 9 #define RUBY_VERSION_TEENY 1 Index: ruby_1_9_2/signal.c =================================================================== --- ruby_1_9_2/signal.c (revision 32925) +++ ruby_1_9_2/signal.c (revision 32926) @@ -566,16 +566,18 @@ { int i, sig = 0; - for (i=1; i<RUBY_NSIG; i++) { - if (signal_buff.cnt[i] > 0) { - rb_disable_interrupt(); - { - ATOMIC_DEC(signal_buff.cnt[i]); - ATOMIC_DEC(signal_buff.size); + if (signal_buff.size != 0) { + for (i=1; i<RUBY_NSIG; i++) { + if (signal_buff.cnt[i] > 0) { + rb_disable_interrupt(); + { + ATOMIC_DEC(signal_buff.cnt[i]); + ATOMIC_DEC(signal_buff.size); + } + rb_enable_interrupt(); + sig = i; + break; } - rb_enable_interrupt(); - sig = i; - break; } } return sig; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/