]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Try to fix issues with reloading config
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 16 Jan 2017 17:24:01 +0000 (17:24 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 16 Jan 2017 17:24:01 +0000 (17:24 +0000)
src/libserver/cfg_rcl.c
src/libserver/cfg_utils.c
src/rspamd.c

index 48f2a9a434329a3ed25856ae42a8002819235071..50704c242752b98ece24195c5185a364d5b580d5 100644 (file)
@@ -586,7 +586,9 @@ rspamd_rcl_worker_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
        qtype = g_quark_try_string (worker_type);
        if (qtype != 0) {
                wrk = rspamd_config_new_worker (cfg, NULL);
+               wrk->options = ucl_object_ref (obj);
                wrk->worker = rspamd_get_worker_by_type (cfg, qtype);
+
                if (wrk->worker == NULL) {
                        g_set_error (err,
                                        CFG_RCL_ERROR,
@@ -595,7 +597,9 @@ rspamd_rcl_worker_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
                                        worker_type);
                        return FALSE;
                }
+
                wrk->type = qtype;
+
                if (wrk->worker->worker_init_func) {
                        wrk->ctx = wrk->worker->worker_init_func (cfg);
                }
@@ -628,8 +632,6 @@ rspamd_rcl_worker_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
                ucl_object_iterate_free (it);
        }
 
-       wrk->options = (ucl_object_t *)obj;
-
        if (!rspamd_rcl_section_parse_defaults (cfg, section, cfg->cfg_pool, obj,
                        wrk, err)) {
                return FALSE;
index b39503ee288ab99959576554ff8d7eb7e04a3932..8a8138ebfa50a2cd53e9016c81f6eea400fb6958 100644 (file)
@@ -943,6 +943,8 @@ static void
 rspamd_worker_conf_dtor (struct rspamd_worker_conf *wcf)
 {
        if (wcf) {
+               /* XXX: fix reload memory leak somehow */
+               /* ucl_object_unref (wcf->options); */
                g_queue_free (wcf->active_workers);
                g_hash_table_unref (wcf->params);
                g_slice_free1 (sizeof (*wcf), wcf);
index 6f4fc0ba16a32fb81bf63cfed019cd4c0ee673e6..4997022625c52308fcac462e55b5356322ea4144 100644 (file)
@@ -322,6 +322,7 @@ rspamd_fork_delayed_cb (gint signo, short what, gpointer arg)
        event_del (&w->wait_ev);
        rspamd_fork_worker (w->rspamd_main, w->cf, w->oldindex,
                        w->rspamd_main->ev_base);
+       REF_RELEASE (w->cf);
        g_slice_free1 (sizeof (*w), w);
 }
 
@@ -333,12 +334,13 @@ rspamd_fork_delayed (struct rspamd_worker_conf *cf,
        struct waiting_worker *nw;
        struct timeval tv;
 
-       nw = g_slice_alloc (sizeof (*nw));
+       nw = g_slice_alloc0 (sizeof (*nw));
        nw->cf = cf;
        nw->oldindex = index;
        nw->rspamd_main = rspamd_main;
        tv.tv_sec = SOFT_FORK_TIME;
        tv.tv_usec = 0;
+       REF_RETAIN (cf);
        event_set (&nw->wait_ev, -1, EV_TIMEOUT, rspamd_fork_delayed_cb, nw);
        event_base_set (rspamd_main->ev_base, &nw->wait_ev);
        event_add (&nw->wait_ev, &tv);
@@ -984,6 +986,7 @@ rspamd_cld_handler (gint signo, short what, gpointer arg)
                        /* We also need to clean descriptors left */
                        close (cur->control_pipe[0]);
                        close (cur->srv_pipe[0]);
+                       REF_RELEASE (cur->cf);
                        g_free (cur);
                }
                else {