diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-03-04 14:42:44 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-03-04 14:42:44 +0000 |
commit | dc069207552c5b837ea3341916e17df031259fd2 (patch) | |
tree | 66d92f268da8190ab91678af68a1f4c06a8d13d3 /src/libserver | |
parent | fade62b49a0d3716cd229805e43c3d7600b607fb (diff) | |
download | rspamd-dc069207552c5b837ea3341916e17df031259fd2.tar.gz rspamd-dc069207552c5b837ea3341916e17df031259fd2.zip |
[Minor] Fix actions setting
Diffstat (limited to 'src/libserver')
-rw-r--r-- | src/libserver/cfg_utils.c | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c index 440ed3e3c..8bd633929 100644 --- a/src/libserver/cfg_utils.c +++ b/src/libserver/cfg_utils.c @@ -827,8 +827,9 @@ rspamd_config_new_metric (struct rspamd_config *cfg, struct metric *c, c->groups = g_hash_table_new (rspamd_str_hash, rspamd_str_equal); for (i = METRIC_ACTION_REJECT; i < METRIC_ACTION_MAX; i++) { - c->actions[i].score = -1.0; + c->actions[i].score = NAN; c->actions[i].action = i; + c->actions[i].priority = 0; } c->subject = SPAM_SUBJECT; @@ -1563,26 +1564,32 @@ rspamd_config_set_action_score (struct rspamd_config *cfg, act = &metric->actions[act_num]; - if (act->priority > priority) { - msg_info_config ("action %s has been already registered with" - "priority %ud, do not override (new priority: %ud)", - action_name, - act->priority, - priority); - return FALSE; + if (isnan (act->score)) { + act->score = score; + act->priority = priority; } else { - msg_info_config ("action %s has been already registered with" - "priority %ud, override it with new priority: %ud, " - "old score: %.2f, new score: %.2f", - action_name, - act->priority, - priority, - act->score, - score); + if (act->priority > priority) { + msg_info_config ("action %s has been already registered with " + "priority %ud, do not override (new priority: %ud)", + action_name, + act->priority, + priority); + return FALSE; + } + else { + msg_info_config ("action %s has been already registered with " + "priority %ud, override it with new priority: %ud, " + "old score: %.2f, new score: %.2f", + action_name, + act->priority, + priority, + act->score, + score); - act->score = score; - act->priority = priority; + act->score = score; + act->priority = priority; + } } return TRUE; |