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,
worker_type);
return FALSE;
}
+
wrk->type = qtype;
+
if (wrk->worker->worker_init_func) {
wrk->ctx = wrk->worker->worker_init_func (cfg);
}
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;
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);
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);
}
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);
/* 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 {