From 74b339e9385181844ee44d155ac59c8544e5016c Mon Sep 17 00:00:00 2001 From: kosaki Date: Sun, 10 Jul 2011 17:04:40 +0000 Subject: [PATCH] * thread_pthread.c (rb_thread_create_timer_thread): removed rb_disable_interrupt()/rb_enable_interrupt(). * vm_core.h: ditto. * process.c (static void before_exec): ditto. * process.c (static void after_exec): ditto. [Bug #4765] [ruby-dev:43571] * eval_intern.h: removed rb_trap_restore_mask(). * vm_eval.c (rb_throw_obj): ditto. * eval.c (setup_exception): ditto. * signal.c: removed trap_last_mask. * signal.c (trap_restore_mask): removed. * signal.c (init_sigchld): comment clarification why signal block is needed. and removed trap_last_mask operation. * signal.c (trap_ensure): removed trap_last_mask operation. * signal.c (rb_disable_interrupt, rb_enable_interrupt): made static and removed sigdelset(SIGVTALARM) and sigdelset(SIGSEGV). * process.c (rb_syswait): removed implicit signal handler change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32510 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 24 ++++++++++++++++++++++++ eval.c | 2 -- eval_intern.h | 1 - process.c | 43 +------------------------------------------ signal.c | 27 ++++++++------------------- thread_pthread.c | 4 ---- vm_core.h | 2 -- vm_eval.c | 1 - 8 files changed, 33 insertions(+), 71 deletions(-) diff --git a/ChangeLog b/ChangeLog index 373937d0d1..856af545c3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,27 @@ +Mon Jul 11 01:16:27 2011 KOSAKI Motohiro + + * thread_pthread.c (rb_thread_create_timer_thread): removed + rb_disable_interrupt()/rb_enable_interrupt(). + * vm_core.h: ditto. + * process.c (static void before_exec): ditto. + * process.c (static void after_exec): ditto. + [Bug #4765] [ruby-dev:43571] + + * eval_intern.h: removed rb_trap_restore_mask(). + * vm_eval.c (rb_throw_obj): ditto. + * eval.c (setup_exception): ditto. + + * signal.c: removed trap_last_mask. + * signal.c (trap_restore_mask): removed. + * signal.c (init_sigchld): comment clarification why signal block + is needed. and removed trap_last_mask operation. + * signal.c (trap_ensure): removed trap_last_mask operation. + + * signal.c (rb_disable_interrupt, rb_enable_interrupt): made + static and removed sigdelset(SIGVTALARM) and sigdelset(SIGSEGV). + + * process.c (rb_syswait): removed implicit signal handler change. + Sun Jul 10 23:49:12 2011 Yuki Sonoda (Yugui) * docs/NEWS-1.9.3: moved from NEWS. diff --git a/eval.c b/eval.c index 783335d9d9..87f1f61ec3 100644 --- a/eval.c +++ b/eval.c @@ -430,8 +430,6 @@ setup_exception(rb_thread_t *th, int tag, volatile VALUE mesg) JUMP_TAG(TAG_FATAL); } - rb_trap_restore_mask(); - if (tag != TAG_FATAL) { EXEC_EVENT_HOOK(th, RUBY_EVENT_RAISE, th->cfp->self, 0, 0); } diff --git a/eval_intern.h b/eval_intern.h index 483e711c34..c4f0c466f9 100644 --- a/eval_intern.h +++ b/eval_intern.h @@ -213,7 +213,6 @@ void rb_vm_set_progname(VALUE filename); void rb_thread_terminate_all(void); VALUE rb_vm_top_self(); VALUE rb_vm_cbase(void); -void rb_trap_restore_mask(void); #ifndef CharNext /* defined as CharNext[AW] on Windows. */ #define CharNext(p) ((p) + mblen((p), RUBY_MBCHAR_MAXSIZE)) diff --git a/process.c b/process.c index 1289db53e4..d811867055 100644 --- a/process.c +++ b/process.c @@ -992,12 +992,6 @@ static RETSIGTYPE sig_do_nothing(int sig) static void before_exec(void) { - /* - * signalmask is inherited across exec() and almost system commands don't - * work if signalmask is blocked. - */ - rb_enable_interrupt(); - #ifdef SIGPIPE /* * Some OS commands don't initialize signal handler properly. Thus we have @@ -1028,7 +1022,6 @@ static void after_exec(void) #endif forked_child = 0; - rb_disable_interrupt(); } #define before_fork() before_exec() @@ -2947,43 +2940,9 @@ rb_f_abort(int argc, VALUE *argv) void rb_syswait(rb_pid_t pid) { - static int overriding; -#ifdef SIGHUP - RETSIGTYPE (*hfunc)(int) = 0; -#endif -#ifdef SIGQUIT - RETSIGTYPE (*qfunc)(int) = 0; -#endif - RETSIGTYPE (*ifunc)(int) = 0; int status; - int i, hooked = FALSE; - if (!overriding) { -#ifdef SIGHUP - hfunc = signal(SIGHUP, SIG_IGN); -#endif -#ifdef SIGQUIT - qfunc = signal(SIGQUIT, SIG_IGN); -#endif - ifunc = signal(SIGINT, SIG_IGN); - overriding = TRUE; - hooked = TRUE; - } - - do { - i = rb_waitpid(pid, &status, 0); - } while (i == -1 && errno == EINTR); - - if (hooked) { -#ifdef SIGHUP - signal(SIGHUP, hfunc); -#endif -#ifdef SIGQUIT - signal(SIGQUIT, qfunc); -#endif - signal(SIGINT, ifunc); - overriding = FALSE; - } + rb_waitpid(pid, &status, 0); } static VALUE diff --git a/signal.c b/signal.c index 7bad8c1d8a..618ed3f52d 100644 --- a/signal.c +++ b/signal.c @@ -519,27 +519,21 @@ rb_signal_buff_size(void) return signal_buff.size; } -#if USE_TRAP_MASK -static sigset_t trap_last_mask; -#endif - #if HAVE_PTHREAD_H #include #endif -void +static void rb_disable_interrupt(void) { #if USE_TRAP_MASK sigset_t mask; sigfillset(&mask); - sigdelset(&mask, SIGVTALRM); - sigdelset(&mask, SIGSEGV); pthread_sigmask(SIG_SETMASK, &mask, NULL); #endif } -void +static void rb_enable_interrupt(void) { #if USE_TRAP_MASK @@ -872,19 +866,10 @@ trap_ensure(struct trap_arg *arg) { /* enable interrupt */ pthread_sigmask(SIG_SETMASK, &arg->mask, NULL); - trap_last_mask = arg->mask; return 0; } #endif -void -rb_trap_restore_mask(void) -{ -#if USE_TRAP_MASK - pthread_sigmask(SIG_SETMASK, &trap_last_mask, NULL); -#endif -} - /* * call-seq: * Signal.trap( signal, command ) -> obj @@ -995,7 +980,12 @@ init_sigchld(int sig) sigset_t mask; sigset_t fullmask; - /* disable interrupt */ + /* + * disable interrupt. Otherwise following temmporal signal handler change + * has a race. + * Note: now we have only single thread, therefore both sigprocmask() and + * pthread_sigmask() makes the same effect. + */ sigfillset(&fullmask); pthread_sigmask(SIG_BLOCK, &fullmask, &mask); #endif @@ -1010,7 +1000,6 @@ init_sigchld(int sig) #if USE_TRAP_MASK sigdelset(&mask, sig); pthread_sigmask(SIG_SETMASK, &mask, NULL); - trap_last_mask = mask; #endif } #endif diff --git a/thread_pthread.c b/thread_pthread.c index 0cdc220fba..d4d3bb5de3 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -1159,8 +1159,6 @@ thread_timer(void *p) static void rb_thread_create_timer_thread(void) { - rb_enable_interrupt(); - if (!timer_thread_id) { pthread_attr_t attr; int err; @@ -1223,8 +1221,6 @@ rb_thread_create_timer_thread(void) exit(EXIT_FAILURE); } } - - rb_disable_interrupt(); /* only timer thread recieve signal */ } static int diff --git a/vm_core.h b/vm_core.h index da912b5b60..8f70174db9 100644 --- a/vm_core.h +++ b/vm_core.h @@ -634,8 +634,6 @@ void rb_vm_bugreport(void); #endif VALUE rb_iseq_eval(VALUE iseqval); VALUE rb_iseq_eval_main(VALUE iseqval); -void rb_enable_interrupt(void); -void rb_disable_interrupt(void); #if defined __GNUC__ && __GNUC__ >= 4 #pragma GCC visibility pop #endif diff --git a/vm_eval.c b/vm_eval.c index 7df7f5f47b..d6e9d6e30b 100644 --- a/vm_eval.c +++ b/vm_eval.c @@ -1441,7 +1441,6 @@ rb_throw_obj(VALUE tag, VALUE value) RB_GC_GUARD(desc); rb_raise(rb_eArgError, "uncaught throw %s", RSTRING_PTR(desc)); } - rb_trap_restore_mask(); th->errinfo = NEW_THROW_OBJECT(tag, 0, TAG_THROW); JUMP_TAG(TAG_THROW);