From: Vsevolod Stakhov Date: Mon, 28 Nov 2016 12:34:27 +0000 (+0000) Subject: [Fix] Fix usage of config during reload X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0b4010ff3f6cffbd1318430f8f9b8cc4d5979aaf;p=thirdparty%2Frspamd.git [Fix] Fix usage of config during reload --- diff --git a/src/controller.c b/src/controller.c index 7280d99511..0d74c019ea 100644 --- a/src/controller.c +++ b/src/controller.c @@ -2695,6 +2695,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); @@ -2859,5 +2860,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 e321aa0b6c..5383944862 100644 --- a/src/fuzzy_storage.c +++ b/src/fuzzy_storage.c @@ -2191,7 +2191,11 @@ start_fuzzy (struct rspamd_worker *worker) "fuzzy", NULL); ctx->peer_fd = -1; + 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, ctx->ev_base, worker->srv->cfg); + rspamd_upstreams_library_config (worker->srv->cfg, ctx->cfg->ups_ctx, ctx->ev_base, ctx->resolver->r); /* * Open DB and perform VACUUM @@ -2290,6 +2294,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 2d39193627..b0ba123d7c 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; @@ -298,6 +299,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 a118f11819..acb1984b9c 100644 --- a/src/log_helper.c +++ b/src/log_helper.c @@ -166,6 +166,7 @@ start_log_helper (struct rspamd_worker *worker) "log_helper", NULL); ctx->cfg = worker->srv->cfg; + REF_RETAIN (ctx->cfg); ctx->scripts = worker->cf->scripts; ctx->L = ctx->cfg->lua_state; @@ -192,6 +193,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 b74b8d4222..986fe0b124 100644 --- a/src/lua_worker.c +++ b/src/lua_worker.c @@ -355,6 +355,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, @@ -412,6 +413,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 917c925ab8..4b11147e02 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); @@ -1498,6 +1500,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 60c39b2af1..9bf4dc74c2 100644 --- a/src/worker.c +++ b/src/worker.c @@ -534,6 +534,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); msec_to_tv (ctx->timeout, &ctx->io_tv); rspamd_symbols_cache_start_refresh (worker->srv->cfg->cache, ctx->ev_base); @@ -579,5 +581,7 @@ start_worker (struct rspamd_worker *worker) g_slice_free1 (sizeof (*lp), lp); } + REF_RELEASE (ctx->cfg); + exit (EXIT_SUCCESS); }