From 26d6ee991131d43edf89d4d34077187527be8562 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 28 Nov 2016 12:34:27 +0000 Subject: [PATCH] [Fix] Fix usage of config during reload --- src/controller.c | 3 +++ src/fuzzy_storage.c | 3 +++ src/hs_helper.c | 2 ++ src/log_helper.c | 2 ++ src/lua_worker.c | 2 ++ src/rspamd_proxy.c | 3 +++ src/worker.c | 4 ++++ 7 files changed, 19 insertions(+) diff --git a/src/controller.c b/src/controller.c index 36261674c..75a502871 100644 --- a/src/controller.c +++ b/src/controller.c @@ -3039,6 +3039,7 @@ start_controller_worker (struct rspamd_worker *worker) ctx->start_time = time (NULL); ctx->worker = worker; ctx->cfg = worker->srv->cfg; + REF_RETAIN (ctx->cfg); ctx->srv = worker->srv; ctx->custom_commands = g_hash_table_new (rspamd_strcase_hash, rspamd_strcase_equal); @@ -3212,5 +3213,7 @@ start_controller_worker (struct rspamd_worker *worker) munmap (m, ctx->cached_enable_password.len); } + REF_RELEASE (ctx->cfg); + exit (EXIT_SUCCESS); } diff --git a/src/fuzzy_storage.c b/src/fuzzy_storage.c index 770337ca5..d023354bf 100644 --- a/src/fuzzy_storage.c +++ b/src/fuzzy_storage.c @@ -2259,6 +2259,8 @@ start_fuzzy (struct rspamd_worker *worker) FALSE); ctx->peer_fd = -1; ctx->worker = worker; + ctx->cfg = worker->srv->cfg; + REF_RETAIN (ctx->cfg); double_to_tv (ctx->master_timeout, &ctx->master_io_tv); ctx->resolver = dns_resolver_init (worker->srv->logger, @@ -2367,6 +2369,7 @@ start_fuzzy (struct rspamd_worker *worker) rspamd_lru_hash_destroy (ctx->errors_ips); g_hash_table_unref (ctx->keys); + REF_RELEASE (ctx->cfg); exit (EXIT_SUCCESS); } diff --git a/src/hs_helper.c b/src/hs_helper.c index 90abdf0be..f4f3bed88 100644 --- a/src/hs_helper.c +++ b/src/hs_helper.c @@ -268,6 +268,7 @@ start_hs_helper (struct rspamd_worker *worker) double tim; ctx->cfg = worker->srv->cfg; + REF_RETAIN (ctx->cfg); if (ctx->hs_dir == NULL) { ctx->hs_dir = ctx->cfg->hs_cache_dir; @@ -299,6 +300,7 @@ start_hs_helper (struct rspamd_worker *worker) rspamd_worker_block_signals (); rspamd_log_close (worker->srv->logger); + REF_RELEASE (ctx->cfg); exit (EXIT_SUCCESS); } diff --git a/src/log_helper.c b/src/log_helper.c index 50db8e805..5030c0fe5 100644 --- a/src/log_helper.c +++ b/src/log_helper.c @@ -188,6 +188,7 @@ start_log_helper (struct rspamd_worker *worker) NULL, TRUE); ctx->cfg = worker->srv->cfg; + REF_RETAIN (ctx->cfg); ctx->scripts = worker->cf->scripts; ctx->L = ctx->cfg->lua_state; ctx->resolver = dns_resolver_init (worker->srv->logger, @@ -222,6 +223,7 @@ start_log_helper (struct rspamd_worker *worker) rspamd_worker_block_signals (); rspamd_log_close (worker->srv->logger); + REF_RELEASE (ctx->cfg); exit (EXIT_SUCCESS); } diff --git a/src/lua_worker.c b/src/lua_worker.c index b3a644566..296910761 100644 --- a/src/lua_worker.c +++ b/src/lua_worker.c @@ -356,6 +356,7 @@ start_lua_worker (struct rspamd_worker *worker) L = worker->srv->cfg->lua_state; ctx->L = L; ctx->cfg = worker->srv->cfg; + REF_RETAIN (ctx->cfg); ctx->resolver = dns_resolver_init (worker->srv->logger, ctx->ev_base, @@ -413,6 +414,7 @@ start_lua_worker (struct rspamd_worker *worker) } rspamd_log_close (worker->srv->logger); + REF_RELEASE (ctx->cfg); exit (EXIT_SUCCESS); } diff --git a/src/rspamd_proxy.c b/src/rspamd_proxy.c index fc30329a8..9f81bcc99 100644 --- a/src/rspamd_proxy.c +++ b/src/rspamd_proxy.c @@ -1464,6 +1464,8 @@ start_rspamd_proxy (struct rspamd_worker *worker) struct rspamd_proxy_ctx *ctx = worker->ctx; struct timeval rot_tv; + ctx->cfg = worker->srv->cfg; + REF_RETAIN (ctx->cfg); ctx->ev_base = rspamd_prepare_worker (worker, "rspamd_proxy", proxy_accept_socket, TRUE); @@ -1499,6 +1501,7 @@ start_rspamd_proxy (struct rspamd_worker *worker) } rspamd_keypair_cache_destroy (ctx->keys_cache); + REF_RELEASE (ctx->cfg); exit (EXIT_SUCCESS); } diff --git a/src/worker.c b/src/worker.c index fcb9d9fe3..df772feb5 100644 --- a/src/worker.c +++ b/src/worker.c @@ -597,6 +597,8 @@ start_worker (struct rspamd_worker *worker) struct rspamd_worker_ctx *ctx = worker->ctx; struct rspamd_worker_log_pipe *lp, *ltmp; + ctx->cfg = worker->srv->cfg; + REF_RETAIN (ctx->cfg); ctx->ev_base = rspamd_prepare_worker (worker, "normal", accept_socket, TRUE); msec_to_tv (ctx->timeout, &ctx->io_tv); rspamd_symbols_cache_start_refresh (worker->srv->cfg->cache, ctx->ev_base); @@ -646,5 +648,7 @@ start_worker (struct rspamd_worker *worker) g_slice_free1 (sizeof (*lp), lp); } + REF_RELEASE (ctx->cfg); + exit (EXIT_SUCCESS); } -- 2.39.5