From 5669349ad3f982ef79e4cd16d2ba2d3119de5faf Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 29 Jan 2014 14:08:14 +0000 Subject: [PATCH] Fix overrides for a metric. Fixes #33 --- src/cfg_rcl.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/cfg_rcl.c b/src/cfg_rcl.c index 0dc41689b..f750b6726 100644 --- a/src/cfg_rcl.c +++ b/src/cfg_rcl.c @@ -365,7 +365,7 @@ rspamd_rcl_metric_handler (struct config_file *cfg, ucl_object_t *obj, } } } - if (!have_actions) { + if (new && !have_actions) { g_set_error (err, CFG_RCL_ERROR, EINVAL, "metric %s has no actions", metric_name); return FALSE; } @@ -405,7 +405,7 @@ rspamd_rcl_metric_handler (struct config_file *cfg, ucl_object_t *obj, } } } - else { + else if (new) { g_set_error (err, CFG_RCL_ERROR, EINVAL, "metric %s has no symbols", metric_name); return FALSE; } @@ -422,8 +422,10 @@ rspamd_rcl_metric_handler (struct config_file *cfg, ucl_object_t *obj, } /* Insert the resulting metric */ - g_hash_table_insert (cfg->metrics, (void *)metric->name, metric); - cfg->metrics_list = g_list_prepend (cfg->metrics_list, metric); + if (new) { + g_hash_table_insert (cfg->metrics, (void *)metric->name, metric); + cfg->metrics_list = g_list_prepend (cfg->metrics_list, metric); + } return TRUE; } -- 2.39.5