aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2020-03-28 16:37:50 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2020-03-28 16:37:50 +0000
commit192c6b791d1c2b42861df6526c663f1d0814ee84 (patch)
treeed75147db4aa301befe8bc510911e67998a0dcdc /src
parent0e1e5111e3aea32e6e001c0b55d43493bac04738 (diff)
downloadrspamd-192c6b791d1c2b42861df6526c663f1d0814ee84.tar.gz
rspamd-192c6b791d1c2b42861df6526c663f1d0814ee84.zip
[Minor] Try harder to avoid races on child termination
Diffstat (limited to 'src')
-rw-r--r--src/libserver/rspamd_control.c6
-rw-r--r--src/rspamd.c3
2 files changed, 9 insertions, 0 deletions
diff --git a/src/libserver/rspamd_control.c b/src/libserver/rspamd_control.c
index 30d959e47..0dc04d291 100644
--- a/src/libserver/rspamd_control.c
+++ b/src/libserver/rspamd_control.c
@@ -427,6 +427,7 @@ rspamd_control_broadcast_cmd (struct rspamd_main *rspamd_main,
while (g_hash_table_iter_next (&it, &k, &v)) {
wrk = v;
+ /* No control pipe */
if (wrk->control_pipe[0] == -1) {
continue;
}
@@ -435,6 +436,11 @@ rspamd_control_broadcast_cmd (struct rspamd_main *rspamd_main,
continue;
}
+ /* Worker is terminating, do not bother sending stuff */
+ if (wrk->state == rspamd_worker_state_terminating) {
+ continue;
+ }
+
memset (&msg, 0, sizeof (msg));
/* Attach fd to the message */
diff --git a/src/rspamd.c b/src/rspamd.c
index 70aed4331..20dc06bdc 100644
--- a/src/rspamd.c
+++ b/src/rspamd.c
@@ -769,6 +769,7 @@ kill_old_workers (gpointer key, gpointer value, gpointer unused)
w->state = rspamd_worker_state_terminating;
kill (w->pid, SIGUSR2);
ev_io_stop (rspamd_main->event_loop, &w->srv_ev);
+ g_hash_table_remove_all (w->control_events_pending);
msg_info_main ("send signal to worker %P", w->pid);
}
else {
@@ -1141,6 +1142,8 @@ rspamd_cld_handler (EV_P_ ev_child *w, struct rspamd_main *rspamd_main,
/* Remove dead child form children list */
g_hash_table_remove (rspamd_main->workers, GSIZE_TO_POINTER (wrk->pid));
+ g_hash_table_remove_all (wrk->control_events_pending);
+
if (wrk->srv_pipe[0] != -1) {
/* Ugly workaround */
if (wrk->tmp_data) {