aboutsummaryrefslogtreecommitdiffstats
path: root/signal.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-18 09:07:36 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-18 09:07:36 +0000
commitfe2f89af9ad6bd87ec91b7042593bc8c7247708b (patch)
treeabc70486d79868a0773368ab39ee94d6b316bed5 /signal.c
parent3bee3527fd397921b3e4aa3ea001d7b2af99b3bc (diff)
downloadruby-fe2f89af9ad6bd87ec91b7042593bc8c7247708b.tar.gz
thread.c (sleep_*): reduce the effect of spurious interrupts
Spurious interrupts from SIGCHLD cause Mutex#sleep (via ConditionVariable#wait) to return early and breaks some use cases. Since these are outside the programs's control with MJIT, we will only consider pending interrupts (e.g. those from Thread#run) and signals which cause a Ruby-level Signal.trap handler to fire as "spurious" wakeups. [ruby-core:88537] [Feature #15002] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64444 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'signal.c')
-rw-r--r--signal.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/signal.c b/signal.c
index 31dd3bbdb0..326179f383 100644
--- a/signal.c
+++ b/signal.c
@@ -1039,7 +1039,7 @@ sig_do_nothing(int sig)
}
#endif
-static void
+static int
signal_exec(VALUE cmd, int safe, int sig)
{
rb_execution_context_t *ec = GET_EC();
@@ -1053,7 +1053,7 @@ signal_exec(VALUE cmd, int safe, int sig)
* 3. rb_signal_exec runs on queued signal
*/
if (IMMEDIATE_P(cmd))
- return;
+ return FALSE;
ec->interrupt_mask |= TRAP_INTERRUPT_MASK;
EC_PUSH_TAG(ec);
@@ -1069,6 +1069,7 @@ signal_exec(VALUE cmd, int safe, int sig)
/* XXX: should be replaced with rb_threadptr_pending_interrupt_enque() */
EC_JUMP_TAG(ec, state);
}
+ return TRUE;
}
void
@@ -1093,7 +1094,8 @@ ruby_sigchld_handler(rb_vm_t *vm)
}
}
-void
+/* returns true if a trap handler was run, false otherwise */
+int
rb_signal_exec(rb_thread_t *th, int sig)
{
rb_vm_t *vm = GET_VM();
@@ -1131,8 +1133,9 @@ rb_signal_exec(rb_thread_t *th, int sig)
rb_threadptr_signal_exit(th);
}
else {
- signal_exec(cmd, safe, sig);
+ return signal_exec(cmd, safe, sig);
}
+ return FALSE;
}
static sighandler_t