aboutsummaryrefslogtreecommitdiffstats
path: root/src/controller.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/controller.c')
-rw-r--r--src/controller.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/controller.c b/src/controller.c
index 99c81b95b..1c533cc0a 100644
--- a/src/controller.c
+++ b/src/controller.c
@@ -2473,13 +2473,13 @@ rspamd_controller_store_saved_stats (struct rspamd_controller_worker_ctx *ctx)
fd = open (ctx->saved_stats_path, O_WRONLY|O_CREAT|O_TRUNC, 00644);
if (fd == -1) {
- msg_err_ctx ("cannot load controller stats from %s: %s",
+ msg_err_ctx ("cannot open for writing controller stats from %s: %s",
ctx->saved_stats_path, strerror (errno));
return;
}
if (rspamd_file_lock (fd, FALSE) == -1) {
- msg_err_ctx ("cannot load controller stats from %s: %s",
+ msg_err_ctx ("cannot lock controller stats in %s: %s",
ctx->saved_stats_path, strerror (errno));
close (fd);
@@ -2660,6 +2660,19 @@ init_controller_worker (struct rspamd_config *cfg)
return ctx;
}
+static void
+rspamd_controller_on_terminate (struct rspamd_worker *worker)
+{
+ struct rspamd_controller_worker_ctx *ctx = worker->ctx;
+
+ rspamd_controller_store_saved_stats (ctx);
+
+ if (ctx->rrd) {
+ event_del (ctx->rrd_event);
+ rspamd_rrd_close (ctx->rrd);
+ }
+}
+
/*
* Start worker process
*/
@@ -2697,6 +2710,8 @@ start_controller_worker (struct rspamd_worker *worker)
DEFAULT_STATS_PATH);
}
+ g_ptr_array_add (worker->finish_actions,
+ (gpointer)rspamd_controller_on_terminate);
rspamd_controller_load_saved_stats (ctx);
/* RRD collector */
@@ -2832,11 +2847,6 @@ start_controller_worker (struct rspamd_worker *worker)
rspamd_stat_close ();
rspamd_http_router_free (ctx->http);
rspamd_log_close (worker->srv->logger);
- rspamd_controller_store_saved_stats (ctx);
-
- if (ctx->rrd) {
- rspamd_rrd_close (ctx->rrd);
- }
if (ctx->cached_password.len > 0) {
m = (gpointer)ctx->cached_password.begin;