diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-06-14 11:47:36 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-06-14 15:15:19 +0100 |
commit | 7406e60b74327df055f3bacfc478bd5cb68fd6c9 (patch) | |
tree | 9589f52da4b7e19f2eb0997674503763107619af /src/libserver/dynamic_cfg.c | |
parent | 700949bd941aeec41060163e36509061791c502f (diff) | |
download | rspamd-7406e60b74327df055f3bacfc478bd5cb68fd6c9.tar.gz rspamd-7406e60b74327df055f3bacfc478bd5cb68fd6c9.zip |
[Fix] Cleanup maps data on shutdown
Diffstat (limited to 'src/libserver/dynamic_cfg.c')
-rw-r--r-- | src/libserver/dynamic_cfg.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/libserver/dynamic_cfg.c b/src/libserver/dynamic_cfg.c index 584590ed9..17818888e 100644 --- a/src/libserver/dynamic_cfg.c +++ b/src/libserver/dynamic_cfg.c @@ -222,6 +222,22 @@ json_config_fin_cb (struct map_cb_data *data) jb->cfg->current_dynamic_conf = top; } +static void +json_config_dtor_cb (struct map_cb_data *data) +{ + struct config_json_buf *jb; + + if (data->cur_data) { + jb = data->cur_data; + /* Clean prev data */ + if (jb->buf) { + g_string_free (jb->buf, TRUE); + } + + g_free (jb); + } +} + /** * Init dynamic configuration using map logic and specific configuration * @param cfg config file @@ -244,8 +260,13 @@ init_dynamic_config (struct rspamd_config *cfg) *pjb = jb; cfg->current_dynamic_conf = ucl_object_typed_new (UCL_ARRAY); - if (!rspamd_map_add (cfg, cfg->dynamic_conf, "Dynamic configuration map", - json_config_read_cb, json_config_fin_cb, (void **)pjb)) { + if (!rspamd_map_add (cfg, + cfg->dynamic_conf, + "Dynamic configuration map", + json_config_read_cb, + json_config_fin_cb, + json_config_dtor_cb, + (void **)pjb)) { msg_err ("cannot add map for configuration %s", cfg->dynamic_conf); } } |