]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Fix options and shots match
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 20 Mar 2017 18:24:19 +0000 (18:24 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 20 Mar 2017 18:24:19 +0000 (18:24 +0000)
src/libmime/filter.c
src/lua/lua_config.c

index 2a6bbae6d8cae5080606e4f3f015671603193ba2..ed949a86a40e34fa954a9a67676bfbf7dc1e6383 100644 (file)
@@ -159,48 +159,57 @@ insert_metric_result (struct rspamd_task *task,
                        single = TRUE;
                }
 
-               s->nshots ++;
+               /* Now check for the duplicate options */
+               if (opt && s->options && g_hash_table_lookup (s->options, opt)) {
+                       single = TRUE;
+               }
+               else {
+                       s->nshots ++;
+               }
+
+               if (!single) {
+                       rspamd_task_add_result_option (task, s, opt);
+               }
 
-               if (rspamd_task_add_result_option (task, s, opt)) {
-                       if (!single) {
-                               diff = w;
+               /* Adjust diff */
+               if (!single) {
+                       diff = w;
+               }
+               else {
+                       if (fabs (s->score) < fabs (w)) {
+                               /* Replace less weight with a bigger one */
+                               diff = metric_res->score - s->score + w;
                        }
                        else {
-                               if (fabs (s->score) < fabs (w)) {
-                                       /* Replace less weight with a bigger one */
-                                       diff = metric_res->score - s->score + w;
-                               }
-                               else {
-                                       diff = 0;
-                               }
+                               diff = 0;
                        }
+               }
 
-                       if (diff) {
-                               /* Handle grow factor */
-                               if (metric_res->grow_factor && diff > 0) {
-                                       diff *= metric_res->grow_factor;
-                                       next_gf *= metric->grow_factor;
-                               }
-                               else if (diff > 0) {
-                                       next_gf = metric->grow_factor;
-                               }
+               if (diff) {
+                       /* Handle grow factor */
+                       if (metric_res->grow_factor && diff > 0) {
+                               diff *= metric_res->grow_factor;
+                               next_gf *= metric->grow_factor;
+                       }
+                       else if (diff > 0) {
+                               next_gf = metric->grow_factor;
+                       }
 
-                               diff = rspamd_check_group_score (task, symbol, gr, gr_score, diff);
+                       diff = rspamd_check_group_score (task, symbol, gr, gr_score, diff);
 
-                               if (!isnan (diff)) {
-                                       metric_res->score += diff;
-                                       metric_res->grow_factor = next_gf;
+                       if (!isnan (diff)) {
+                               metric_res->score += diff;
+                               metric_res->grow_factor = next_gf;
 
-                                       if (gr_score) {
-                                               *gr_score += diff;
-                                       }
+                               if (gr_score) {
+                                       *gr_score += diff;
+                               }
 
-                                       if (single) {
-                                               s->score = w;
-                                       }
-                                       else {
-                                               s->score += diff;
-                                       }
+                               if (single) {
+                                       s->score = w;
+                               }
+                               else {
+                                       s->score += diff;
                                }
                        }
                }
index e83e9a699a9d1f6185cc0fcd029ef7d403555040..654035dabcafe61b0494f91413611140b0ecdc31 100644 (file)
@@ -1499,7 +1499,7 @@ lua_config_set_metric_symbol (lua_State * L)
                                        "nshots=I",
                                        &name, &weight, &description,
                                        &group, &one_shot, &one_param,
-                                       &metric_name, &priority, &flags_str)) {
+                                       &metric_name, &priority, &flags_str, &nshots)) {
                                msg_err_config ("bad arguments: %e", err);
                                g_error_free (err);