diff options
Diffstat (limited to 'src/libserver/cfg_utils.c')
-rw-r--r-- | src/libserver/cfg_utils.c | 47 |
1 files changed, 39 insertions, 8 deletions
diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c index bd2aac89b..eba9d66d9 100644 --- a/src/libserver/cfg_utils.c +++ b/src/libserver/cfg_utils.c @@ -162,6 +162,10 @@ rspamd_config_new (void) void rspamd_config_free (struct rspamd_config *cfg) { + struct rspamd_dynamic_module *dyn_mod; + struct rspamd_dynamic_worker *dyn_wrk; + GList *cur; + rspamd_map_remove_all (cfg); ucl_object_unref (cfg->rcl_obj); ucl_object_unref (cfg->doc_strings); @@ -182,6 +186,28 @@ rspamd_config_free (struct rspamd_config *cfg) g_free (cfg->checksum); } + /* Unload dynamic workers/modules */ + cur = g_list_first (cfg->dynamic_modules); + while (cur) { + dyn_mod = cur->data; + + if (dyn_mod->lib) { + g_module_close (dyn_mod->lib); + } + + cur = g_list_next (cur); + } + cur = g_list_first (cfg->dynamic_workers); + while (cur) { + dyn_wrk = cur->data; + + if (dyn_wrk->lib) { + g_module_close (dyn_wrk->lib); + } + + cur = g_list_next (cur); + } + g_list_free (cfg->classifiers); g_list_free (cfg->metrics_list); rspamd_symbols_cache_destroy (cfg->cache); @@ -1192,6 +1218,7 @@ rspamd_init_filters (struct rspamd_config *cfg, bool reconfig) { GList *cur; module_t *mod, **pmod; + struct rspamd_dynamic_module *dyn_mod; struct module_ctx *mod_ctx; /* Init all compiled modules */ @@ -1214,16 +1241,20 @@ rspamd_init_filters (struct rspamd_config *cfg, bool reconfig) cur = g_list_first (cfg->dynamic_modules); while (cur) { - mod = cur->data; + dyn_mod = cur->data; - if (rspamd_check_module (cfg, mod)) { - mod_ctx = g_slice_alloc0 (sizeof (struct module_ctx)); + if (dyn_mod->lib) { + mod = &dyn_mod->mod; - if (mod->module_init_func (cfg, &mod_ctx) == 0) { - g_hash_table_insert (cfg->c_modules, - (gpointer) mod->name, - mod_ctx); - mod_ctx->mod = mod; + if (rspamd_check_module (cfg, mod)) { + mod_ctx = g_slice_alloc0 (sizeof (struct module_ctx)); + + if (mod->module_init_func (cfg, &mod_ctx) == 0) { + g_hash_table_insert (cfg->c_modules, + (gpointer) mod->name, + mod_ctx); + mod_ctx->mod = mod; + } } } |