mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* eval.c (ruby_cleanup): before cleanup, check signal buffer and run
handler if any. [ruby-core:20970] * thread.c (rb_threadptr_check_signal): separeted from timer_thread_function. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27513 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
6fd326e76c
commit
4af243a8af
4 changed files with 45 additions and 10 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
Tue Apr 27 21:24:40 2010 Yusuke Endoh <mame@tsg.ne.jp>
|
||||||
|
|
||||||
|
* eval.c (ruby_cleanup): before cleanup, check signal buffer and run
|
||||||
|
handler if any. [ruby-core:20970]
|
||||||
|
|
||||||
|
* thread.c (rb_threadptr_check_signal): separeted from
|
||||||
|
timer_thread_function.
|
||||||
|
|
||||||
Tue Apr 27 18:00:50 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Tue Apr 27 18:00:50 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* lib/net/smtp.rb (Net::SMTP#rcptto_list): fixed typo.
|
* lib/net/smtp.rb (Net::SMTP#rcptto_list): fixed typo.
|
||||||
|
|
6
eval.c
6
eval.c
|
@ -127,6 +127,12 @@ ruby_cleanup(volatile int ex)
|
||||||
volatile VALUE errs[2];
|
volatile VALUE errs[2];
|
||||||
rb_thread_t *th = GET_THREAD();
|
rb_thread_t *th = GET_THREAD();
|
||||||
int nerr;
|
int nerr;
|
||||||
|
void rb_threadptr_interrupt(rb_thread_t *th);
|
||||||
|
void rb_threadptr_check_signal(rb_thread_t *mth);
|
||||||
|
|
||||||
|
rb_threadptr_interrupt(th);
|
||||||
|
rb_threadptr_check_signal(th);
|
||||||
|
RUBY_VM_CHECK_INTS();
|
||||||
|
|
||||||
errs[1] = th->errinfo;
|
errs[1] = th->errinfo;
|
||||||
th->safe_level = 0;
|
th->safe_level = 0;
|
||||||
|
|
|
@ -36,7 +36,7 @@ class TestSignal < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_exit_action
|
def test_exit_action
|
||||||
return unless have_fork? # snip this test
|
return unless have_fork? # skip this test
|
||||||
begin
|
begin
|
||||||
r, w = IO.pipe
|
r, w = IO.pipe
|
||||||
r0, w0 = IO.pipe
|
r0, w0 = IO.pipe
|
||||||
|
@ -166,4 +166,17 @@ class TestSignal < Test::Unit::TestCase
|
||||||
Signal.trap(:INT, oldtrap) if oldtrap
|
Signal.trap(:INT, oldtrap) if oldtrap
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_kill_immediately_before_termination
|
||||||
|
return unless have_fork? # skip this test
|
||||||
|
|
||||||
|
r, w = IO.pipe
|
||||||
|
pid = Process.fork do
|
||||||
|
r.close
|
||||||
|
Signal.trap(:USR1) { w.syswrite("foo") }
|
||||||
|
Process.kill :USR1, $$
|
||||||
|
end
|
||||||
|
w.close
|
||||||
|
assert_equal(r.read, "foo")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
26
thread.c
26
thread.c
|
@ -290,7 +290,7 @@ reset_unblock_function(rb_thread_t *th, const struct rb_unblock_callback *old)
|
||||||
native_mutex_unlock(&th->interrupt_lock);
|
native_mutex_unlock(&th->interrupt_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
void
|
||||||
rb_threadptr_interrupt(rb_thread_t *th)
|
rb_threadptr_interrupt(rb_thread_t *th)
|
||||||
{
|
{
|
||||||
native_mutex_lock(&th->interrupt_lock);
|
native_mutex_lock(&th->interrupt_lock);
|
||||||
|
@ -2651,18 +2651,13 @@ rb_gc_save_machine_context(rb_thread_t *th)
|
||||||
|
|
||||||
int rb_get_next_signal(void);
|
int rb_get_next_signal(void);
|
||||||
|
|
||||||
static void
|
void
|
||||||
timer_thread_function(void *arg)
|
rb_threadptr_check_signal(rb_thread_t *mth)
|
||||||
{
|
{
|
||||||
rb_vm_t *vm = GET_VM(); /* TODO: fix me for Multi-VM */
|
|
||||||
int sig;
|
int sig;
|
||||||
rb_thread_t *mth;
|
|
||||||
|
|
||||||
/* for time slice */
|
/* mth must be main_thread */
|
||||||
RUBY_VM_SET_TIMER_INTERRUPT(vm->running_thread);
|
|
||||||
|
|
||||||
/* check signal */
|
|
||||||
mth = vm->main_thread;
|
|
||||||
if (!mth->exec_signal && (sig = rb_get_next_signal()) > 0) {
|
if (!mth->exec_signal && (sig = rb_get_next_signal()) > 0) {
|
||||||
enum rb_thread_status prev_status = mth->status;
|
enum rb_thread_status prev_status = mth->status;
|
||||||
thread_debug("main_thread: %s, sig: %d\n",
|
thread_debug("main_thread: %s, sig: %d\n",
|
||||||
|
@ -2672,6 +2667,19 @@ timer_thread_function(void *arg)
|
||||||
rb_threadptr_interrupt(mth);
|
rb_threadptr_interrupt(mth);
|
||||||
mth->status = prev_status;
|
mth->status = prev_status;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
timer_thread_function(void *arg)
|
||||||
|
{
|
||||||
|
rb_vm_t *vm = GET_VM(); /* TODO: fix me for Multi-VM */
|
||||||
|
rb_thread_t *mth;
|
||||||
|
|
||||||
|
/* for time slice */
|
||||||
|
RUBY_VM_SET_TIMER_INTERRUPT(vm->running_thread);
|
||||||
|
|
||||||
|
/* check signal */
|
||||||
|
rb_threadptr_check_signal(vm->main_thread);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/* prove profiler */
|
/* prove profiler */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue