]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Fix dynamic settings application
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 12 Jun 2018 14:13:03 +0000 (15:13 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 12 Jun 2018 14:13:03 +0000 (15:13 +0100)
Issue: #769
Closes: #769
src/libserver/dynamic_cfg.c
src/plugins/lua/dynamic_conf.lua

index 1211585261a11559953981806b31149f652d2bf0..584590ed978c4ebb650617f1bf306736379e9b6b 100644 (file)
@@ -152,7 +152,6 @@ json_config_read_cb (gchar * chunk,
        if (data->cur_data == NULL) {
                jb = g_malloc0 (sizeof (*jb));
                jb->cfg = pd->cfg;
-               jb->buf = pd->buf;
                data->cur_data = jb;
        }
        else {
@@ -161,7 +160,7 @@ json_config_read_cb (gchar * chunk,
 
        if (jb->buf == NULL) {
                /* Allocate memory for buffer */
-               jb->buf = g_string_sized_new (BUFSIZ);
+               jb->buf = g_string_sized_new (MAX (len, BUFSIZ));
        }
 
        g_string_append_len (jb->buf, chunk, len);
@@ -179,6 +178,10 @@ json_config_fin_cb (struct map_cb_data *data)
        if (data->prev_data) {
                jb = data->prev_data;
                /* Clean prev data */
+               if (jb->buf) {
+                       g_string_free (jb->buf, TRUE);
+               }
+
                g_free (jb);
        }
 
@@ -190,6 +193,7 @@ json_config_fin_cb (struct map_cb_data *data)
                msg_err ("no data read");
                return;
        }
+
        if (jb->buf == NULL) {
                msg_err ("no data read");
                return;
index 29f63e90caff61ebdd5b81bc0e586d0909efe0b1..ffe1f7e9c78a7fd79bcad714e61ef3367def9950 100644 (file)
@@ -319,10 +319,15 @@ local function add_dynamic_action(_, act, score)
   return add
 end
 
-if redis_params then
-  rspamd_plugins["dynamic_conf"] = {
-    add_symbol = add_dynamic_symbol,
-    add_action = add_dynamic_action,
-  }
-  lua_util.disable_module(N, "redis")
-end
+if section then
+  if redis_params then
+    rspamd_plugins["dynamic_conf"] = {
+      add_symbol = add_dynamic_symbol,
+      add_action = add_dynamic_action,
+    }
+  else
+    lua_util.disable_module(N, "redis")
+  end
+else
+  lua_util.disable_module(N, "config")
+end
\ No newline at end of file