ruby-changes:16237
From: shyouhei <ko1@a...>
Date: Tue, 8 Jun 2010 12:58:47 +0900 (JST)
Subject: [ruby-changes:16237] Ruby:r28203 (ruby_1_8_7): merge revision(s) 26371,26373,26374,26972:
shyouhei 2010-06-08 12:58:37 +0900 (Tue, 08 Jun 2010) New Revision: 28203 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=28203 Log: merge revision(s) 26371,26373,26374,26972: * eval.c (thread_timer, rb_thread_stop_timer): check the timing of stopping timer. patch from KOSAKI Motohiro <kosaki.motohiro _AT_ jp.fujitsu.com> * eval.c (rb_thread_start_timer): NetBSD5 seems to be hung when calling pthread_create() from pthread_atfork()'s parent handler. * io.c (pipe_open): workaround for NetBSD5. stop timer thread before fork(), and start it if needed. * process.c (rb_f_fork, rb_f_system): ditto. fixed [ruby-dev:40074] jp.fujitsu.com> via IRC. fork(), and restart it after fork() on parent, and on child if needed. these changes are tested by naruse. fixed [ruby-dev:40074] * io.c, eval.c, process.c: add linux to r26371's condition. patched by Motohiro KOSAKI [ruby-core:28151] Modified files: branches/ruby_1_8_7/ChangeLog branches/ruby_1_8_7/eval.c branches/ruby_1_8_7/io.c branches/ruby_1_8_7/process.c branches/ruby_1_8_7/version.h Index: ruby_1_8_7/process.c =================================================================== --- ruby_1_8_7/process.c (revision 28202) +++ ruby_1_8_7/process.c (revision 28203) @@ -1330,7 +1330,14 @@ fflush(stderr); #endif - switch (pid = fork()) { +#if defined(__NetBSD__) || defined(__APPLE__) || defined(linux) + before_exec(); +#endif + pid = fork(); +#if defined(__NetBSD__) || defined(__APPLE__) || defined(linux) + after_exec(); +#endif + switch (pid) { case 0: #ifdef linux after_exec(); @@ -1570,6 +1577,9 @@ chfunc = signal(SIGCHLD, SIG_DFL); retry: +#if defined(__NetBSD__) || defined(__APPLE__) || defined(linux) + before_exec(); +#endif pid = fork(); if (pid == 0) { /* child process */ @@ -1577,6 +1587,9 @@ rb_protect(proc_exec_args, (VALUE)&earg, NULL); _exit(127); } +#if defined(__NetBSD__) || defined(__APPLE__) || defined(linux) + after_exec(); +#endif if (pid < 0) { if (errno == EAGAIN) { rb_thread_sleep(1); Index: ruby_1_8_7/ChangeLog =================================================================== --- ruby_1_8_7/ChangeLog (revision 28202) +++ ruby_1_8_7/ChangeLog (revision 28203) @@ -1,3 +1,25 @@ +Tue Jun 8 12:37:56 2010 NARUSE, Yui <naruse@r...> + + * io.c, eval.c, process.c: add linux to r26371's condition. + patched by Motohiro KOSAKI [ruby-core:28151] + +Tue Jun 8 12:37:56 2010 NAKAMURA Usaku <usa@r...> + + * eval.c (thread_timer, rb_thread_stop_timer): check the timing of + stopping timer. patch from KOSAKI Motohiro <kosaki.motohiro _AT_ + jp.fujitsu.com> via IRC. + + * eval.c (rb_thread_start_timer): NetBSD5 seems to be hung when calling + pthread_create() from pthread_atfork()'s parent handler. + + * io.c (pipe_open): workaround for NetBSD5. stop timer thread before + fork(), and restart it after fork() on parent, and on child if + needed. + + * process.c (rb_f_fork, rb_f_system): ditto. + + these changes are tested by naruse. fixed [ruby-dev:40074] + Mon Jun 7 19:23:04 2010 Nobuyoshi Nakada <nobu@r...> * ext/nkf/nkf-utf8/nkf.c (numchar_getc): get rid of buffer Index: ruby_1_8_7/version.h =================================================================== --- ruby_1_8_7/version.h (revision 28202) +++ ruby_1_8_7/version.h (revision 28203) @@ -1,15 +1,15 @@ #define RUBY_VERSION "1.8.7" -#define RUBY_RELEASE_DATE "2010-06-07" +#define RUBY_RELEASE_DATE "2010-06-08" #define RUBY_VERSION_CODE 187 -#define RUBY_RELEASE_CODE 20100607 -#define RUBY_PATCHLEVEL 268 +#define RUBY_RELEASE_CODE 20100608 +#define RUBY_PATCHLEVEL 269 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 8 #define RUBY_VERSION_TEENY 7 #define RUBY_RELEASE_YEAR 2010 #define RUBY_RELEASE_MONTH 6 -#define RUBY_RELEASE_DAY 7 +#define RUBY_RELEASE_DAY 8 #ifdef RUBY_EXTERN RUBY_EXTERN const char ruby_version[]; Index: ruby_1_8_7/io.c =================================================================== --- ruby_1_8_7/io.c (revision 28202) +++ ruby_1_8_7/io.c (revision 28203) @@ -3251,6 +3251,9 @@ } retry: +#if defined(__NetBSD__) || defined(__APPLE__) || defined(linux) + rb_thread_stop_timer(); +#endif switch ((pid = fork())) { case 0: /* child */ if (modef & FMODE_READABLE) { @@ -3278,11 +3281,17 @@ ruby_sourcefile, ruby_sourceline, pname); _exit(127); } +#if defined(__NetBSD__) || defined(__APPLE__) || defined(linux) + rb_thread_start_timer(); +#endif rb_io_synchronized(RFILE(orig_stdout)->fptr); rb_io_synchronized(RFILE(orig_stderr)->fptr); return Qnil; case -1: /* fork failed */ +#if defined(__NetBSD__) || defined(__APPLE__) || defined(linux) + rb_thread_start_timer(); +#endif if (errno == EAGAIN) { rb_thread_sleep(1); goto retry; @@ -3303,6 +3312,9 @@ break; default: /* parent */ +#if defined(__NetBSD__) || defined(__APPLE__) || defined(linux) + rb_thread_start_timer(); +#endif if (pid < 0) rb_sys_fail(pname); else { VALUE port = io_alloc(rb_cIO); Index: ruby_1_8_7/eval.c =================================================================== --- ruby_1_8_7/eval.c (revision 28202) +++ ruby_1_8_7/eval.c (revision 28203) @@ -12292,6 +12292,8 @@ pthread_t thread; } time_thread = {PTHREAD_COND_INITIALIZER, PTHREAD_MUTEX_INITIALIZER}; +static int timer_stopping; + #define safe_mutex_lock(lock) \ pthread_mutex_lock(lock); \ pthread_cleanup_push((void (*)_((void *)))pthread_mutex_unlock, lock) @@ -12316,6 +12318,9 @@ #define WAIT_FOR_10MS() \ pthread_cond_timedwait(&running->cond, &running->lock, get_ts(&to, PER_NANO/100)) while ((err = WAIT_FOR_10MS()) == EINTR || err == ETIMEDOUT) { + if (timer_stopping) + break; + if (!rb_thread_critical) { rb_thread_pending = 1; if (rb_trap_immediate) { @@ -12343,7 +12348,9 @@ safe_mutex_lock(&time_thread.lock); if (pthread_create(&time_thread.thread, 0, thread_timer, args) == 0) { thread_init = 1; +#if !defined(__NetBSD__) && !defined(__APPLE__) && !defined(linux) pthread_atfork(0, 0, rb_thread_stop_timer); +#endif pthread_cond_wait(&start, &time_thread.lock); } pthread_cleanup_pop(1); @@ -12354,10 +12361,12 @@ { if (!thread_init) return; safe_mutex_lock(&time_thread.lock); + timer_stopping = 1; pthread_cond_signal(&time_thread.cond); thread_init = 0; pthread_cleanup_pop(1); pthread_join(time_thread.thread, NULL); + timer_stopping = 0; } #elif defined(HAVE_SETITIMER) static void -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/