diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-02-12 22:11:59 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-02-12 22:11:59 +0000 |
commit | 6cf47b32aa9cf5811c96d44cc416749c83c4580b (patch) | |
tree | 3b181b7d0106e35ac617c12af772b483fdbad66f | |
parent | 907307283325f2d0335e217cb806b07af9ecb978 (diff) | |
download | ruby-6cf47b32aa9cf5811c96d44cc416749c83c4580b.tar.gz |
* (ruby_vm_send_signal): deal with signals properly.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/mvm@26653 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | thread.c | 10 | ||||
-rw-r--r-- | vm_core.h | 15 |
3 files changed, 20 insertions, 9 deletions
@@ -1,3 +1,7 @@ +Sat Feb 13 07:11:57 2010 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * (ruby_vm_send_signal): deal with signals properly. + Sat Nov 21 01:03:39 2009 Nobuyoshi Nakada <nobu@ruby-lang.org> * thread.c (rb_queue_mark): mark possible objects. @@ -1379,7 +1379,7 @@ rb_threadptr_execute_interrupts_rec(rb_thread_t *th, int sched_depth) rb_vm_t *vm = GET_VM(); if (vm->main_thread == th) { - while (rb_signal_buff_size() && !(th->interrupt_flag & 0x08)) { + while (rb_signal_buff_size() && !(th->interrupt_flag & ruby_vm_signal_bit)) { native_thread_yield(); } } @@ -1388,8 +1388,8 @@ rb_threadptr_execute_interrupts_rec(rb_thread_t *th, int sched_depth) 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 timer_interrupt = th->interrupt_flag & ruby_vm_timer_bit; + int finalizer_interrupt = th->interrupt_flag & ruby_vm_finalizer_bit; void *exec_signal; th->status = THREAD_RUNNABLE; @@ -2806,11 +2806,11 @@ ruby_vm_send_signal(rb_vm_t *vm, int sig) if (sig <= 0 || sig >= RUBY_NSIG) return -1; mth = vm->main_thread; - if (mth->interrupt_flag) return -1; + if (mth->interrupt_flag & ruby_vm_signal_bit) return -1; prev_status = mth->status; thread_debug("main_thread: %s, sig: %d\n", thread_status_name(prev_status), sig); - mth->interrupt_flag |= 0x08; + mth->interrupt_flag |= ruby_vm_signal_bit; rb_queue_push(&mth->queue.signal, (void *)INT2FIX(sig)); if (mth->status != THREAD_KILLED) mth->status = THREAD_RUNNABLE; rb_threadptr_interrupt(mth); @@ -733,10 +733,17 @@ int ruby_thread_set_native(rb_thread_t *th); #error "unsupported thread model" #endif -#define RUBY_VM_SET_INTERRUPT(th) ((th)->interrupt_flag |= 0x02) -#define RUBY_VM_SET_TIMER_INTERRUPT(th) ((th)->interrupt_flag |= 0x01) -#define RUBY_VM_SET_FINALIZER_INTERRUPT(th) ((th)->interrupt_flag |= 0x04) -#define RUBY_VM_INTERRUPTED(th) ((th)->interrupt_flag & 0x02) +enum { + ruby_vm_timer_bit = 0x01, + ruby_vm_interrupt_bit = 0x02, + ruby_vm_finalizer_bit = 0x04, + ruby_vm_signal_bit = 0x08 +}; + +#define RUBY_VM_SET_INTERRUPT(th) ((th)->interrupt_flag |= ruby_vm_interrupt_bit) +#define RUBY_VM_SET_TIMER_INTERRUPT(th) ((th)->interrupt_flag |= ruby_vm_timer_bit) +#define RUBY_VM_SET_FINALIZER_INTERRUPT(th) ((th)->interrupt_flag |= ruby_vm_finalizer_bit) +#define RUBY_VM_INTERRUPTED(th) ((th)->interrupt_flag & ruby_vm_interrupt_bit) void rb_threadptr_signal_raise(rb_thread_t *th, int sig); void rb_threadptr_signal_exit(rb_thread_t *th); |