diff options
author | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-05-22 22:32:16 +0000 |
---|---|---|
committer | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-05-22 22:32:16 +0000 |
commit | 8d44e350f902986124f58d7786da86dfca1bc0d5 (patch) | |
tree | 13ce0332da855996fc66ba8dd2270072ba9e40b3 | |
parent | 2faba093569c034989b27f2380e67311670d225f (diff) |
* process.c (proc_exec_v): terminate timer thread in advance.
[ruby-dev:30581], Thanks H. Holon.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_6@12343 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | eval.c | 32 | ||||
-rw-r--r-- | process.c | 1 | ||||
-rw-r--r-- | version.h | 2 |
4 files changed, 39 insertions, 1 deletions
@@ -1,3 +1,8 @@ +Wed May 23 07:29:53 2007 URABE Shyouhei <shyouhei@ruby-lang.org> + + * 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 <shyouhei@ruby-lang.org> * lib/cgi.rb (CGI#[]): get rid of exceptions being raised. @@ -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 @@ -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; @@ -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 |