Skip to content

Commit

Permalink
[Rework] Rework config reload
Browse files Browse the repository at this point in the history
  • Loading branch information
vstakhov committed Aug 7, 2019
1 parent 87baef1 commit ab3d1bc
Showing 1 changed file with 25 additions and 14 deletions.
39 changes: 25 additions & 14 deletions src/rspamd.c
Expand Up @@ -277,6 +277,8 @@ reread_config (struct rspamd_main *rspamd_main)
{
struct rspamd_config *tmp_cfg, *old_cfg;
gchar *cfg_file;
int load_opts = RSPAMD_CONFIG_INIT_VALIDATE|RSPAMD_CONFIG_INIT_SYMCACHE|
RSPAMD_CONFIG_INIT_LIBS|RSPAMD_CONFIG_INIT_URL;

rspamd_symcache_save (rspamd_main->cfg->cache);
tmp_cfg = rspamd_config_new (RSPAMD_CONFIG_INIT_DEFAULT);
Expand All @@ -289,10 +291,7 @@ reread_config (struct rspamd_main *rspamd_main)
old_cfg = rspamd_main->cfg;
rspamd_main->cfg = tmp_cfg;

if (!load_rspamd_config (rspamd_main, tmp_cfg, TRUE,
RSPAMD_CONFIG_INIT_VALIDATE|RSPAMD_CONFIG_INIT_SYMCACHE|
RSPAMD_CONFIG_INIT_LIBS|RSPAMD_CONFIG_INIT_URL,
TRUE)) {
if (!load_rspamd_config (rspamd_main, tmp_cfg, TRUE, load_opts, TRUE)) {
rspamd_main->cfg = old_cfg;
rspamd_log_close_priv (rspamd_main->logger,
FALSE,
Expand All @@ -309,6 +308,16 @@ reread_config (struct rspamd_main *rspamd_main)
else {
msg_info_main ("replacing config");
REF_RELEASE (old_cfg);
/* Here, we can do post actions with the existing config */
/*
* As some rules are defined in lua, we need to process them, then init
* modules and merely afterwards to init modules
*/
rspamd_lua_post_load_config (tmp_cfg);
rspamd_init_filters (tmp_cfg, TRUE);

/* Do post-load actions */
rspamd_config_post_load (tmp_cfg, load_opts);
msg_info_main ("config has been reread successfully");
rspamd_map_preload (rspamd_main->cfg);

Expand Down Expand Up @@ -871,19 +880,21 @@ load_rspamd_config (struct rspamd_main *rspamd_main,
}
}

/*
* As some rules are defined in lua, we need to process them, then init
* modules and merely afterwards to init modules
*/
rspamd_lua_post_load_config (cfg);
if (!reload) {
/*
* As some rules are defined in lua, we need to process them, then init
* modules and merely afterwards to init modules
*/
rspamd_lua_post_load_config (cfg);

if (init_modules) {
rspamd_init_filters (cfg, reload);
}

if (init_modules) {
rspamd_init_filters (cfg, reload);
/* Do post-load actions */
rspamd_config_post_load (cfg, opts);
}

/* Do post-load actions */
rspamd_config_post_load (cfg, opts);

return TRUE;
}

Expand Down

0 comments on commit ab3d1bc

Please sign in to comment.