Some signals can only be handled on specific threads; we block them on all
others to prevent the wrong thread from handling a signal. But if a
library (in our case DPDK) spawns a thread, it may inherit a permissive
signal mask and handle the signal itself, resulting in confusing.
Fix by blocking all signals early, before libraries get a chance to spawn
threads.
See scylladb/scylla#601.
---
v2: leave some signals (that we don't handle) unmasked to preserve
default behavior
core/reactor.cc | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/core/reactor.cc b/core/reactor.cc
index e1e34f9..d6c47ca 100644
--- a/core/reactor.cc
+++ b/core/reactor.cc
@@ -2309,6 +2309,19 @@ void smp::cleanup() {
void smp::configure(boost::program_options::variables_map configuration)
{
+ // Mask most, to prevent threads (esp. dpdk helper threads)
+ // from servicing a signal. Individual reactors will unmask signals
+ // as they become prepared to handle them.
+ //
+ // We leave some signals unmasked since we don't handle them ourself.
+ sigset_t sigs;
+ sigfillset(&sigs);
+ for (auto sig : {SIGHUP, SIGQUIT, SIGILL, SIGABRT, SIGFPE, SIGSEGV,
+ SIGALRM, SIGCONT, SIGSTOP, SIGTSTP, SIGTTIN, SIGTTOU}) {
+ sigdelset(&sigs, sig);
+ }