From: Vsevolod Stakhov Date: Fri, 4 Mar 2016 14:42:44 +0000 (+0000) Subject: [Minor] Fix actions setting X-Git-Tag: 1.2.0~120 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dc069207552c5b837ea3341916e17df031259fd2;p=thirdparty%2Frspamd.git [Minor] Fix actions setting --- diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c index 440ed3e3c0..8bd633929a 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;