@@ -3346,7 +3346,6 @@ 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); | |||
@@ -3529,9 +3528,9 @@ start_controller_worker (struct rspamd_worker *worker) | |||
munmap (m, ctx->cached_enable_password.len); | |||
} | |||
REF_RELEASE (ctx->cfg); | |||
g_hash_table_unref (ctx->plugins); | |||
g_hash_table_unref (ctx->custom_commands); | |||
REF_RELEASE (ctx->cfg); | |||
exit (EXIT_SUCCESS); | |||
} |
@@ -2303,7 +2303,6 @@ start_fuzzy (struct rspamd_worker *worker) | |||
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, |
@@ -268,7 +268,6 @@ 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; |
@@ -128,7 +128,8 @@ rspamd_config_new (void) | |||
cfg->classifiers_symbols = g_hash_table_new (rspamd_str_hash, | |||
rspamd_str_equal); | |||
cfg->cfg_params = g_hash_table_new (rspamd_str_hash, rspamd_str_equal); | |||
cfg->metrics_symbols = g_hash_table_new (rspamd_str_hash, rspamd_str_equal); | |||
cfg->metrics_symbols = g_hash_table_new_full (rspamd_str_hash, rspamd_str_equal, | |||
NULL, (GDestroyNotify)g_list_free); | |||
cfg->debug_modules = g_hash_table_new (rspamd_str_hash, rspamd_str_equal); | |||
cfg->explicit_modules = g_hash_table_new (rspamd_str_hash, rspamd_str_equal); | |||
cfg->wrk_parsers = g_hash_table_new (g_int_hash, g_int_equal); | |||
@@ -191,6 +192,29 @@ rspamd_config_free (struct rspamd_config *cfg) | |||
struct rspamd_config_post_load_script *sc, *sctmp; | |||
rspamd_map_remove_all (cfg); | |||
DL_FOREACH_SAFE (cfg->finish_callbacks, sc, sctmp) { | |||
luaL_unref (cfg->lua_state, LUA_REGISTRYINDEX, sc->cbref); | |||
g_slice_free1 (sizeof (*sc), sc); | |||
} | |||
DL_FOREACH_SAFE (cfg->on_load, sc, sctmp) { | |||
luaL_unref (cfg->lua_state, LUA_REGISTRYINDEX, sc->cbref); | |||
g_slice_free1 (sizeof (*sc), sc); | |||
} | |||
if (cfg->monitored_ctx) { | |||
rspamd_monitored_ctx_destroy (cfg->monitored_ctx); | |||
} | |||
g_list_free (cfg->classifiers); | |||
g_list_free (cfg->metrics_list); | |||
rspamd_symbols_cache_destroy (cfg->cache); | |||
#ifdef WITH_HIREDIS | |||
if (cfg->redis_pool) { | |||
rspamd_redis_pool_destroy (cfg->redis_pool); | |||
} | |||
#endif | |||
ucl_object_unref (cfg->rcl_obj); | |||
ucl_object_unref (cfg->config_comments); | |||
ucl_object_unref (cfg->doc_strings); | |||
@@ -213,28 +237,11 @@ rspamd_config_free (struct rspamd_config *cfg) | |||
g_free (cfg->checksum); | |||
} | |||
DL_FOREACH_SAFE (cfg->finish_callbacks, sc, sctmp) { | |||
luaL_unref (cfg->lua_state, LUA_REGISTRYINDEX, sc->cbref); | |||
g_slice_free1 (sizeof (*sc), sc); | |||
} | |||
DL_FOREACH_SAFE (cfg->on_load, sc, sctmp) { | |||
luaL_unref (cfg->lua_state, LUA_REGISTRYINDEX, sc->cbref); | |||
g_slice_free1 (sizeof (*sc), sc); | |||
} | |||
if (cfg->monitored_ctx) { | |||
rspamd_monitored_ctx_destroy (cfg->monitored_ctx); | |||
} | |||
g_list_free (cfg->classifiers); | |||
g_list_free (cfg->metrics_list); | |||
rspamd_symbols_cache_destroy (cfg->cache); | |||
REF_RELEASE (cfg->libs_ctx); | |||
rspamd_re_cache_unref (cfg->re_cache); | |||
rspamd_upstreams_library_unref (cfg->ups_ctx); | |||
rspamd_mempool_delete (cfg->cfg_pool); | |||
lua_close (cfg->lua_state); | |||
REF_RELEASE (cfg->libs_ctx); | |||
g_slice_free1 (sizeof (*cfg), cfg); | |||
} | |||
@@ -1210,7 +1217,6 @@ rspamd_ucl_fin_cb (struct map_cb_data *data) | |||
data->prev_data; | |||
ucl_object_t *obj; | |||
struct ucl_parser *parser; | |||
guint32 checksum; | |||
ucl_object_iter_t it = NULL; | |||
const ucl_object_t *cur; | |||
struct rspamd_config *cfg = data->map->cfg; | |||
@@ -1227,7 +1233,6 @@ rspamd_ucl_fin_cb (struct map_cb_data *data) | |||
return; | |||
} | |||
checksum = rspamd_cryptobox_fast_hash (cbdata->buf->str, cbdata->buf->len, 0); | |||
/* New data available */ | |||
parser = ucl_parser_new (0); | |||
if (!ucl_parser_add_chunk (parser, cbdata->buf->str, | |||
@@ -1398,9 +1403,6 @@ rspamd_config_new_metric_symbol (struct rspamd_config *cfg, | |||
if ((metric_list = | |||
g_hash_table_lookup (cfg->metrics_symbols, sym_def->name)) == NULL) { | |||
metric_list = g_list_prepend (NULL, metric); | |||
rspamd_mempool_add_destructor (cfg->cfg_pool, | |||
(rspamd_mempool_destruct_t)g_list_free, | |||
metric_list); | |||
g_hash_table_insert (cfg->metrics_symbols, sym_def->name, metric_list); | |||
} | |||
else { |
@@ -112,7 +112,9 @@ rspamd_redis_pool_conn_dtor (struct rspamd_redis_pool_connection *conn) | |||
} | |||
} | |||
g_queue_unlink (conn->elt->active, conn->entry); | |||
if (conn->entry) { | |||
g_queue_unlink (conn->elt->active, conn->entry); | |||
} | |||
} | |||
else { | |||
msg_debug_rpool ("inactive connection removed"); | |||
@@ -132,7 +134,9 @@ rspamd_redis_pool_conn_dtor (struct rspamd_redis_pool_connection *conn) | |||
redisAsyncFree (ac); | |||
} | |||
g_queue_unlink (conn->elt->inactive, conn->entry); | |||
if (conn->entry) { | |||
g_queue_unlink (conn->elt->inactive, conn->entry); | |||
} | |||
} | |||
@@ -149,11 +153,13 @@ rspamd_redis_pool_elt_dtor (gpointer p) | |||
for (cur = elt->active->head; cur != NULL; cur = g_list_next (cur)) { | |||
c = cur->data; | |||
c->entry = NULL; | |||
REF_RELEASE (c); | |||
} | |||
for (cur = elt->inactive->head; cur != NULL; cur = g_list_next (cur)) { | |||
c = cur->data; | |||
c->entry = NULL; | |||
REF_RELEASE (c); | |||
} | |||
@@ -161,7 +161,6 @@ rspamd_stat_init (struct rspamd_config *cfg, struct event_base *ev_base) | |||
stat_ctx->classifiers = g_ptr_array_new (); | |||
stat_ctx->async_elts = g_queue_new (); | |||
stat_ctx->ev_base = ev_base; | |||
REF_RETAIN (stat_ctx->cfg); | |||
/* Create statfiles from the classifiers */ | |||
cur = cfg->classifiers; | |||
@@ -336,7 +335,6 @@ rspamd_stat_close (void) | |||
g_queue_free (stat_ctx->async_elts); | |||
g_ptr_array_free (st_ctx->statfiles, TRUE); | |||
g_ptr_array_free (st_ctx->classifiers, TRUE); | |||
REF_RELEASE (stat_ctx->cfg); | |||
g_slice_free1 (sizeof (*st_ctx), st_ctx); | |||
/* Set global var to NULL */ |
@@ -188,7 +188,6 @@ 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, |
@@ -356,7 +356,6 @@ 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, |
@@ -1465,7 +1465,6 @@ start_rspamd_proxy (struct rspamd_worker *worker) | |||
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); |
@@ -82,6 +82,7 @@ rspamd_worker_finalize (gpointer user_data) | |||
msg_info_task ("finishing actions has been processed, terminating"); | |||
event_base_loopexit (task->ev_base, &tv); | |||
rspamd_session_destroy (task->s); | |||
return TRUE; | |||
} | |||
@@ -111,6 +112,8 @@ rspamd_worker_call_finish_handlers (struct rspamd_worker *worker) | |||
} | |||
if (rspamd_session_pending (task->s)) { | |||
rspamd_session_destroy (task->s); | |||
return TRUE; | |||
} | |||
} | |||
@@ -599,7 +602,6 @@ start_worker (struct rspamd_worker *worker) | |||
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); |