From 48efa44719d03eb067d27b30c68cf821074aedce Mon Sep 17 00:00:00 2001 From: normal Date: Wed, 20 Jun 2018 23:38:21 +0000 Subject: thread_pthread.c: fix non-sleepy timer-thread with fork This fixes bootstraptest/test_fork.rb for systems with sleepy timer thread disabled. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63709 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- thread_pthread.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'thread_pthread.c') diff --git a/thread_pthread.c b/thread_pthread.c index 78c66a0c63..40cb601f32 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -975,7 +975,6 @@ native_thread_create(rb_thread_t *th) return err; } -#if USE_SLEEPY_TIMER_THREAD static void native_thread_join(pthread_t th) { @@ -984,8 +983,6 @@ native_thread_join(pthread_t th) rb_raise(rb_eThreadError, "native_thread_join() failed (%d)", err); } } -#endif - #if USE_NATIVE_THREAD_PRIORITY @@ -1622,8 +1619,8 @@ native_stop_timer_thread(void) stopped = --system_working <= 0; if (TT_DEBUG) fprintf(stderr, "stop timer thread\n"); -#if USE_SLEEPY_TIMER_THREAD if (stopped) { +#if USE_SLEEPY_TIMER_THREAD /* prevent wakeups from signal handler ASAP */ timer_thread_pipe.owner_process = 0; @@ -1639,18 +1636,20 @@ native_stop_timer_thread(void) /* stop writing ends of pipes so timer thread notices EOF */ CLOSE_INVALIDATE(normal[1]); CLOSE_INVALIDATE(low[1]); +#endif /* timer thread will stop looping when system_working <= 0: */ native_thread_join(timer_thread.id); +#if USE_SLEEPY_TIMER_THREAD /* timer thread will close the read end on exit: */ VM_ASSERT(timer_thread_pipe.normal[0] == -1); VM_ASSERT(timer_thread_pipe.low[0] == -1); +#endif if (TT_DEBUG) fprintf(stderr, "joined timer thread\n"); timer_thread.created = 0; } -#endif return stopped; } -- cgit v1.2.3