aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver/worker_util.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2014-11-07 15:08:09 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2014-11-07 15:08:09 +0000
commitfdbed6409b116cca8f1e934b55dcbe77022269ea (patch)
treee952a91a7398a22ef01fae37b65e5533106d1bac /src/libserver/worker_util.c
parentba082b46bed8d1a15380ba35f37d1f74f2e0d47d (diff)
downloadrspamd-fdbed6409b116cca8f1e934b55dcbe77022269ea.tar.gz
rspamd-fdbed6409b116cca8f1e934b55dcbe77022269ea.zip
Stop use-after-free in event loop termination.
Diffstat (limited to 'src/libserver/worker_util.c')
-rw-r--r--src/libserver/worker_util.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/libserver/worker_util.c b/src/libserver/worker_util.c
index 0c304feb0..17c5ba872 100644
--- a/src/libserver/worker_util.c
+++ b/src/libserver/worker_util.c
@@ -64,13 +64,12 @@ rspamd_worker_usr2_handler (gint fd, short what, void *arg)
tv.tv_sec = SOFT_SHUTDOWN_TIME;
tv.tv_usec = 0;
wanna_die = 1;
- rspamd_worker_stop_accept (sigh->worker);
msg_info ("worker's shutdown is pending in %d sec", SOFT_SHUTDOWN_TIME);
event_base_loopexit (sigh->base, &tv);
- }
-
- if (sigh->post_handler) {
- sigh->post_handler (sigh->handler_data);
+ if (sigh->post_handler) {
+ sigh->post_handler (sigh->handler_data);
+ }
+ rspamd_worker_stop_accept (sigh->worker);
}
}
@@ -102,14 +101,14 @@ rspamd_worker_term_handler (gint fd, short what, void *arg)
wanna_die = 1;
tv.tv_sec = 0;
tv.tv_usec = 0;
+ if (sigh->post_handler) {
+ sigh->post_handler (sigh->handler_data);
+ }
event_base_loopexit (sigh->base, &tv);
#ifdef WITH_GPERF_TOOLS
ProfilerStop ();
#endif
- }
-
- if (sigh->post_handler) {
- sigh->post_handler (sigh->handler_data);
+ rspamd_worker_stop_accept (sigh->worker);
}
}