From: Vsevolod Stakhov Date: Thu, 3 Oct 2019 14:23:02 +0000 (+0100) Subject: [Fix] Do not use config pool to avoid issues with double reload X-Git-Tag: 2.0~79 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=046a4a15092f741350a6be24b769ea5562572af1;p=rspamd.git [Fix] Do not use config pool to avoid issues with double reload --- diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c index dd2578c91..2d4da27ac 100644 --- a/src/libserver/cfg_utils.c +++ b/src/libserver/cfg_utils.c @@ -83,9 +83,7 @@ rspamd_parse_bind_line (struct rspamd_config *cfg, return FALSE; } - cnf = - rspamd_mempool_alloc0 (cfg->cfg_pool, - sizeof (struct rspamd_worker_bind_conf)); + cnf = g_malloc0 (sizeof (struct rspamd_worker_bind_conf)); cnf->cnt = 1024; cnf->bind_line = str; @@ -94,10 +92,10 @@ rspamd_parse_bind_line (struct rspamd_config *cfg, /* The actual socket will be passed by systemd environment */ cnf->is_systemd = TRUE; cnf->cnt = strtoul (str + sizeof ("systemd:") - 1, &err, 10); - cnf->addrs = NULL; + cnf->addrs = g_ptr_array_new (); if (err == NULL || *err == '\0') { - cnf->name = rspamd_mempool_strdup (cfg->cfg_pool, str); + cnf->name = g_strdup (str); LL_PREPEND (cf->bind_conf, cnf); } else { @@ -107,7 +105,7 @@ rspamd_parse_bind_line (struct rspamd_config *cfg, } else { if (rspamd_parse_host_port_priority (str, &cnf->addrs, - NULL, &cnf->name, DEFAULT_BIND_PORT, cfg->cfg_pool) == RSPAMD_PARSE_ADDR_FAIL) { + NULL, &cnf->name, DEFAULT_BIND_PORT, NULL) == RSPAMD_PARSE_ADDR_FAIL) { msg_err_config ("cannot parse bind line: %s", str); ret = FALSE; } @@ -117,6 +115,15 @@ rspamd_parse_bind_line (struct rspamd_config *cfg, } } + if (!ret) { + if (cnf->addrs) { + g_ptr_array_free (cnf->addrs, TRUE); + } + + g_free (cnf->name); + g_free (cnf); + } + return ret; } @@ -1066,6 +1073,14 @@ static void rspamd_worker_conf_dtor (struct rspamd_worker_conf *wcf) { if (wcf) { + struct rspamd_worker_bind_conf *cnf, *tmp; + + LL_FOREACH_SAFE (wcf->bind_conf, cnf, tmp) { + g_free (cnf->name); + g_ptr_array_free (cnf->addrs, TRUE); + g_free (cnf); + } + ucl_object_unref (wcf->options); g_queue_free (wcf->active_workers); g_hash_table_unref (wcf->params);