summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-01-16 04:07:04 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-01-16 04:07:04 +0000
commit566072ec8da1a8ee8a40f235f38f2498cd7057f5 (patch)
tree22fc13bfe4836586e2f8dfbca4867bed2c286154 /thread.c
parent36c95beb5a38f089e0c93b03c771c3f2b985f4e5 (diff)
merges r21582 from trunk into ruby_1_9_1.
* thread.c (rb_thread_execute_interrupts): if signal is already buffered, main thread should wait until timer thread delivers it. * thread.c (timer_thread_function): should defer delivery of a signal if main thread does not yet trap a previous one. [ruby-dev:37676] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@21594 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/thread.c b/thread.c
index 630176505c..6459ba7a0c 100644
--- a/thread.c
+++ b/thread.c
@@ -1179,6 +1179,10 @@ thread_s_pass(VALUE klass)
void
rb_thread_execute_interrupts(rb_thread_t *th)
{
+ 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) {
@@ -2518,13 +2522,14 @@ timer_thread_function(void *arg)
{
rb_vm_t *vm = GET_VM(); /* TODO: fix me for Multi-VM */
int sig;
+ rb_thread_t *mth;
/* for time slice */
RUBY_VM_SET_TIMER_INTERRUPT(vm->running_thread);
/* check signal */
- if ((sig = rb_get_next_signal()) > 0) {
- rb_thread_t *mth = vm->main_thread;
+ mth = vm->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);