diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-01-17 13:36:14 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-01-17 14:09:51 +0000 |
commit | 049599ba091eefc089ebcccccaf53cd5e10ba875 (patch) | |
tree | fcab81e794997bf92bfef689ac0726036365cb9c /src/rspamd.c | |
parent | deb0241180eb94d393c54659e21ebdc66d9b712f (diff) | |
download | rspamd-049599ba091eefc089ebcccccaf53cd5e10ba875.tar.gz rspamd-049599ba091eefc089ebcccccaf53cd5e10ba875.zip |
[Fix] Fix race condition in SIGUSR2 handler
MFH: true
Diffstat (limited to 'src/rspamd.c')
-rw-r--r-- | src/rspamd.c | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/src/rspamd.c b/src/rspamd.c index f50025105..e3860ee59 100644 --- a/src/rspamd.c +++ b/src/rspamd.c @@ -917,6 +917,7 @@ rspamd_cld_handler (gint signo, short what, gpointer arg) gint res = 0; struct rspamd_worker *cur; pid_t wrk; + gboolean need_refork = TRUE; /* Turn off locking for logger */ rspamd_log_nolock (rspamd_main->logger); @@ -943,27 +944,36 @@ rspamd_cld_handler (gint signo, short what, gpointer arg) #ifdef WCOREDUMP if (WCOREDUMP (res)) { msg_warn_main ( - "%s process %P terminated abnormally by signal: %d" + "%s process %P terminated abnormally by signal: %s" " and created core file", g_quark_to_string (cur->type), cur->pid, - WTERMSIG (res)); + g_strsignal (WTERMSIG (res))); } else { msg_warn_main ( - "%s process %P terminated abnormally by signal: %d" + "%s process %P terminated abnormally by signal: %s" " but NOT created core file", g_quark_to_string (cur->type), cur->pid, - WTERMSIG (res)); + g_strsignal (WTERMSIG (res))); } #else msg_warn_main ( - "%s process %P terminated abnormally by signal: %d", + "%s process %P terminated abnormally by signal: %s", g_quark_to_string (cur->type), cur->pid, - WTERMSIG (res)); + g_strsignal (WTERMSIG (res))); #endif + if (WTERMSIG (res) == SIGUSR2) { + /* + * It is actually race condition when not started process + * has been requested to be reloaded. + * + * We shouldn't refork on this + */ + need_refork = FALSE; + } } else { msg_warn_main ("%s process %P terminated abnormally " @@ -972,9 +982,12 @@ rspamd_cld_handler (gint signo, short what, gpointer arg) cur->pid, WEXITSTATUS (res)); } - /* Fork another worker in replace of dead one */ - rspamd_check_core_limits (rspamd_main); - rspamd_fork_delayed (cur->cf, cur->index, rspamd_main); + + if (need_refork) { + /* Fork another worker in replace of dead one */ + rspamd_check_core_limits (rspamd_main); + rspamd_fork_delayed (cur->cf, cur->index, rspamd_main); + } } event_del (&cur->srv_ev); |