commit 12f80b1: [Minor] Fix redefining of `one_shot` and other `nshots` related attrs
Vsevolod Stakhov
vsevolod at highsecure.ru
Fri Nov 8 16:00:07 UTC 2019
Author: Vsevolod Stakhov
Date: 2019-11-08 15:55:17 +0000
URL: https://github.com/rspamd/rspamd/commit/12f80b153d46944e6fb009bf80a6f1db3fbc80be (HEAD -> master)
[Minor] Fix redefining of `one_shot` and other `nshots` related attrs
---
src/libserver/cfg_rcl.c | 3 +--
src/libserver/cfg_utils.c | 18 ++++++++++++++++--
2 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c
index e4924ae20..c7d414df4 100644
--- a/src/libserver/cfg_rcl.c
+++ b/src/libserver/cfg_rcl.c
@@ -456,11 +456,10 @@ rspamd_rcl_symbol_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
const gchar *description = NULL;
gdouble score = NAN;
guint priority = 1, flags = 0;
- gint nshots;
+ gint nshots = 0;
g_assert (key != NULL);
cfg = sd->cfg;
- nshots = cfg->default_max_shots;
if ((elt = ucl_object_lookup (obj, "one_shot")) != NULL) {
if (ucl_object_type (elt) != UCL_BOOLEAN) {
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,
More information about the Commits
mailing list