summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-08-11 00:39:16 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-08-11 00:39:16 +0000
commit4197f337b9881accd21c15ca0f225dae752f5fd3 (patch)
tree357766f994266743569616b34bca4125e6caff9d /thread.c
parent01d1a35a77f6dc2e522d27379d5a52b8e8a1e9eb (diff)
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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@32926 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c27
1 files changed, 8 insertions, 19 deletions
diff --git a/thread.c b/thread.c
index 10da7fff02..f8be654e6a 100644
--- a/thread.c
+++ b/thread.c
@@ -985,7 +985,7 @@ rb_thread_check_ints(void)
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 @@ thread_s_pass(VALUE klass)
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 @@ int rb_get_next_signal(void);
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;
}
}