aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver/cfg_utils.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-11-08 15:55:17 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-11-08 15:55:17 +0000
commit12f80b153d46944e6fb009bf80a6f1db3fbc80be (patch)
treef245024b66e560ee646ab3fd892516a2ecb15864 /src/libserver/cfg_utils.c
parent66005f3fa335c9f9acc37a7315ec5ab5d3abde66 (diff)
downloadrspamd-12f80b153d46944e6fb009bf80a6f1db3fbc80be.tar.gz
rspamd-12f80b153d46944e6fb009bf80a6f1db3fbc80be.zip
[Minor] Fix redefining of `one_shot` and other `nshots` related attrs
Diffstat (limited to 'src/libserver/cfg_utils.c')
-rw-r--r--src/libserver/cfg_utils.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c
index 59840847b..ba009cc81 100644
--- a/src/libserver/cfg_utils.c
+++ b/src/libserver/cfg_utils.c
@@ -1598,7 +1598,7 @@ rspamd_config_new_symbol (struct rspamd_config *cfg, const gchar *symbol,
sym_def->weight_ptr = score_ptr;
sym_def->name = rspamd_mempool_strdup (cfg->cfg_pool, symbol);
sym_def->flags = flags;
- sym_def->nshots = nshots;
+ sym_def->nshots = nshots != 0 ? nshots : cfg->default_max_shots;
sym_def->groups = g_ptr_array_sized_new (1);
rspamd_mempool_add_destructor (cfg->cfg_pool, rspamd_ptr_array_free_hard,
sym_def->groups);
@@ -1700,6 +1700,11 @@ rspamd_config_add_symbol (struct rspamd_config *cfg,
description);
}
+ /* Or nshots in case of non-default setting */
+ if (nshots != 0 && sym_def->nshots == cfg->default_max_shots) {
+ sym_def->nshots = nshots;
+ }
+
return FALSE;
}
else {
@@ -1720,7 +1725,16 @@ rspamd_config_add_symbol (struct rspamd_config *cfg,
}
sym_def->flags = flags;
- sym_def->nshots = nshots;
+
+ if (nshots != 0) {
+ sym_def->nshots = nshots;
+ }
+ else {
+ /* Do not reset unless we have exactly lower priority */
+ if (sym_def->priority < priority) {
+ sym_def->nshots = cfg->default_max_shots;
+ }
+ }
if (description) {
sym_def->description = rspamd_mempool_strdup (cfg->cfg_pool,