diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-09-16 07:51:07 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-09-16 07:51:07 +0000 |
commit | ce897307b0837ec5c1fc75fdc8ccf1f168741dbe (patch) | |
tree | 24108b89ccce9e2fc664c6f9325bd4c3a6cbcd7c /eval.c | |
parent | 7239e8e06e69972aed1d7991f684a214c2bb896d (diff) |
* eval.c (rb_thread_start_timer): start to catch SIGVTALRM together
with timer thread. [ruby-core:25606]
* eval.c (rb_thread_atfork): stop timer thread.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@24958 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 23 |
1 files changed, 15 insertions, 8 deletions
@@ -12415,6 +12415,12 @@ rb_thread_alloc(klass) static int thread_init; +#if defined(POSIX_SIGNAL) +#define CATCH_VTALRM() posix_signal(SIGVTALRM, catch_timer) +#else +#define CATCH_VTALRM() signal(SIGVTALRM, catch_timer) +#endif + #if defined(_THREAD_SAFE) static void catch_timer(sig) @@ -12498,6 +12504,8 @@ rb_thread_start_timer() static pthread_cond_t start = PTHREAD_COND_INITIALIZER; if (thread_init) return; + if (rb_thread_alone()) return; + CATCH_VTALRM(); args[0] = &time_thread; args[1] = &start; safe_mutex_lock(&time_thread.lock); @@ -12539,6 +12547,8 @@ rb_thread_start_timer() struct itimerval tval; if (thread_init) return; + if (rb_thread_alone()) return; + CATCH_VTALRM(); tval.it_interval.tv_sec = 0; tval.it_interval.tv_usec = 10000; tval.it_value = tval.it_interval; @@ -12618,17 +12628,11 @@ rb_thread_start_0(fn, arg, th) "can't start a new thread (frozen ThreadGroup)"); } - if (!thread_init) { #if defined(HAVE_SETITIMER) || defined(_THREAD_SAFE) -#if defined(POSIX_SIGNAL) - posix_signal(SIGVTALRM, catch_timer); -#else - signal(SIGVTALRM, catch_timer); -#endif - + if (!thread_init) { rb_thread_start_timer(); -#endif } +#endif if (THREAD_SAVE_CONTEXT(curr_thread)) { return thread; @@ -13439,6 +13443,9 @@ rb_thread_atfork() main_thread = curr_thread; curr_thread->next = curr_thread; curr_thread->prev = curr_thread; +#if defined(HAVE_SETITIMER) || defined(_THREAD_SAFE) + rb_thread_stop_timer(); +#endif } |