aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-01-16 17:24:01 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-01-16 17:24:01 +0000
commit2991e3909d87eb266ab763e105e908ea13bf1129 (patch)
treea37e36095208768a435eec1688984f43366da612 /src
parentb74e2a3884fffed26c2d440abfd87949c2390085 (diff)
downloadrspamd-2991e3909d87eb266ab763e105e908ea13bf1129.tar.gz
rspamd-2991e3909d87eb266ab763e105e908ea13bf1129.zip
[Fix] Try to fix issues with reloading config
Diffstat (limited to 'src')
-rw-r--r--src/libserver/cfg_rcl.c6
-rw-r--r--src/libserver/cfg_utils.c2
-rw-r--r--src/rspamd.c5
3 files changed, 10 insertions, 3 deletions
diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c
index 48f2a9a43..50704c242 100644
--- a/src/libserver/cfg_rcl.c
+++ b/src/libserver/cfg_rcl.c
@@ -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;
diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c
index b39503ee2..8a8138ebf 100644
--- a/src/libserver/cfg_utils.c
+++ b/src/libserver/cfg_utils.c
@@ -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);
diff --git a/src/rspamd.c b/src/rspamd.c
index 6f4fc0ba1..499702262 100644
--- a/src/rspamd.c
+++ b/src/rspamd.c
@@ -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 {