From 9e7b082f68a541d9310be7e7323c14b175cecace Mon Sep 17 00:00:00 2001 From: shyouhei Date: Tue, 22 May 2007 22:32:16 +0000 Subject: * process.c (proc_exec_v): terminate timer thread in advance. [ruby-dev:30581], Thanks H. Holon. git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8_6@12343 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ eval.c | 32 ++++++++++++++++++++++++++++++++ process.c | 1 + version.h | 2 +- 4 files changed, 39 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 80d60f29e..decdac9e3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed May 23 07:29:53 2007 URABE Shyouhei + + * process.c (proc_exec_v): terminate timer thread in advance. + [ruby-dev:30581], Thanks H. Holon. + Wed May 23 06:51:46 2007 URABE Shyouhei * lib/cgi.rb (CGI#[]): get rid of exceptions being raised. diff --git a/eval.c b/eval.c index 1bf06b7ee..f0b5368f0 100644 --- a/eval.c +++ b/eval.c @@ -11747,21 +11747,31 @@ catch_timer(sig) /* cause EINTR */ } +static int time_thread_alive_p = 0; static pthread_t time_thread; static void* thread_timer(dummy) void *dummy; { +#ifdef _THREAD_SAFE +#define test_cancel() pthread_testcancel() +#else +#define test_cancel() /* void */ +#endif + for (;;) { #ifdef HAVE_NANOSLEEP struct timespec req, rem; + test_cancel(); req.tv_sec = 0; req.tv_nsec = 10000000; nanosleep(&req, &rem); #else struct timeval tv; + + test_cancel(); tv.tv_sec = 0; tv.tv_usec = 10000; select(0, NULL, NULL, NULL, &tv); @@ -11773,6 +11783,7 @@ thread_timer(dummy) } } } +#undef test_cancel } void @@ -11784,6 +11795,20 @@ void rb_thread_stop_timer() { } + +void +rb_thread_cancel_timer() +{ +#ifdef _THREAD_SAFE + if( time_thread_alive_p ) + { + pthread_cancel( time_thread ); + pthread_join( time_thread, NULL ); + time_thread_alive_p = 0; + } + thread_init = 0; +#endif +} #elif defined(HAVE_SETITIMER) static void catch_timer(sig) @@ -11821,6 +11846,12 @@ rb_thread_stop_timer() tval.it_value = tval.it_interval; setitimer(ITIMER_VIRTUAL, &tval, NULL); } + +void +rb_thread_cancel_timer() +{ +} + #else /* !(_THREAD_SAFE || HAVE_SETITIMER) */ int rb_thread_tick = THREAD_TICK; #endif @@ -11853,6 +11884,7 @@ rb_thread_start_0(fn, arg, th) #ifdef _THREAD_SAFE pthread_create(&time_thread, 0, thread_timer, 0); + time_thread_alive_p = 1; #else rb_thread_start_timer(); #endif diff --git a/process.c b/process.c index 3aaf68962..14efe58d0 100644 --- a/process.c +++ b/process.c @@ -981,6 +981,7 @@ proc_exec_v(argv, prog) } #endif /* MSDOS or __human68k__ or __EMX__ */ before_exec(); + rb_thread_cancel_timer(); execv(prog, argv); after_exec(); return -1; diff --git a/version.h b/version.h index 02360d421..85b9fb0f0 100644 --- a/version.h +++ b/version.h @@ -2,7 +2,7 @@ #define RUBY_RELEASE_DATE "2007-05-23" #define RUBY_VERSION_CODE 186 #define RUBY_RELEASE_CODE 20070523 -#define RUBY_PATCHLEVEL 26 +#define RUBY_PATCHLEVEL 27 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 8 -- cgit