ruby-changes:52180
From: normal <ko1@a...>
Date: Thu, 16 Aug 2018 17:26:58 +0900 (JST)
Subject: [ruby-changes:52180] normal:r64388 (trunk): thread_pthread.c: check signals from gvl.timer
normal 2018-08-16 17:26:51 +0900 (Thu, 16 Aug 2018) New Revision: 64388 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=64388 Log: thread_pthread.c: check signals from gvl.timer For (rare) blocking functions which are not affected by signals, we need to call the appropriate unblocking function via `threadptr_trap_interrupt' While we're at it, handling waitpid/SIGCHLD from gvl.timer isn't harmful, here. Modified files: trunk/thread_pthread.c Index: thread_pthread.c =================================================================== --- thread_pthread.c (revision 64387) +++ thread_pthread.c (revision 64388) @@ -121,6 +121,7 @@ static const struct timespec *sigwait_ti https://github.com/ruby/ruby/blob/trunk/thread_pthread.c#L121 const struct timespec *, int *drained_p); static void ubf_timer_disarm(void); +static void threadptr_trap_interrupt(rb_thread_t *); #define TIMER_THREAD_CREATED_P() (signal_self_pipe.owner_process == getpid()) @@ -193,7 +194,21 @@ do_gvl_timer(rb_vm_t *vm, rb_thread_t *t https://github.com/ruby/ruby/blob/trunk/thread_pthread.c#L194 vm->gvl.timer = th; err = native_cond_timedwait(&nd->cond.gvlq, &vm->gvl.lock, &ts); vm->gvl.timer = 0; + ubf_wakeup_all_threads(); + ruby_sigchld_handler(vm); + if (UNLIKELY(rb_signal_buff_size())) { + if (th == vm->main_thread) { + RUBY_VM_SET_TRAP_INTERRUPT(th->ec); + } + else { + /* unlock is needed because threadptr_trap_interrupt may + * call ubf_select which also acquires vm->gvl.lock */ + rb_native_mutex_unlock(&vm->gvl.lock); + threadptr_trap_interrupt(vm->main_thread); + rb_native_mutex_lock(&vm->gvl.lock); + } + } /* * Timeslice. Warning: the process may fork while this -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/