]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Fix usage of config during reload
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 28 Nov 2016 12:34:27 +0000 (12:34 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 28 Nov 2016 12:34:49 +0000 (12:34 +0000)
src/controller.c
src/fuzzy_storage.c
src/hs_helper.c
src/log_helper.c
src/lua_worker.c
src/rspamd_proxy.c
src/worker.c

index 36261674c2382b4d226bcffbd57549c00fccb785..75a502871905c9cbed658dc6ec1239d1dad881d0 100644 (file)
@@ -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);
 }
index 770337ca5d716240672bd72de623a5724203f4c1..d023354bf24868fff9189025105504d3a4493a0e 100644 (file)
@@ -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);
 }
index 90abdf0be3e8ace5a1e7c4f2dde915131c802504..f4f3bed88018408f056a911a6a64ad58a73f2e9b 100644 (file)
@@ -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);
 }
index 50db8e805fab80394b2c6a0843d1e721cca686b3..5030c0fe5ae20c882e53746a99e809b847e59c1f 100644 (file)
@@ -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);
 }
index b3a6445666796ad0b4db58c01b1c4c154ddf829a..296910761d3f1d287b04092a14f05f68ebdbfba7 100644 (file)
@@ -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);
 }
 
index fc30329a887cea21f1fcee707578f60f411ec7e8..9f81bcc992fcd435e9ab4ca4f5174f2aac39b29e 100644 (file)
@@ -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);
 }
index fcb9d9fe309450d1cb16b1b8bd0d91bf805e63dd..df772feb5da0d02a7a980eaccd0e87b4a125d709 100644 (file)
@@ -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);
 }