]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Store actions limits in metric result
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 29 Mar 2016 08:59:11 +0000 (09:59 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 29 Mar 2016 08:59:11 +0000 (09:59 +0100)
src/libmime/filter.c
src/libmime/filter.h
src/libserver/protocol.c
src/libserver/task.c
src/libstat/stat_process.c

index cc34fcb0ce8146fc4df2bfd9e1d0a2b0f5eb150c..f5c8198214152c50ae761f68ddf1814aafe0fbe4 100644 (file)
@@ -29,6 +29,7 @@ rspamd_create_metric_result (struct rspamd_task *task, const gchar *name)
 {
        struct metric_result *metric_res;
        struct metric *metric;
+       guint i;
 
        metric_res = g_hash_table_lookup (task->results, name);
 
@@ -53,12 +54,16 @@ rspamd_create_metric_result (struct rspamd_task *task, const gchar *name)
        rspamd_mempool_add_destructor (task->task_pool,
                        (rspamd_mempool_destruct_t) g_hash_table_unref,
                        metric_res->sym_groups);
-       metric_res->checked = FALSE;
        metric_res->metric = metric;
        metric_res->grow_factor = 0;
        metric_res->score = 0;
        g_hash_table_insert (task->results, (gpointer) metric->name,
                        metric_res);
+
+       for (i = 0; i < METRIC_ACTION_MAX; i++) {
+               metric_res->actions_limits[i] = metric->actions[i].score;
+       }
+
        metric_res->action = METRIC_ACTION_MAX;
 
        return metric_res;
index bacbede06d4951d5d4faafa4056b1165db825aa0..6bb0ef4e98a41524c5a3ee6ce70d94020eb8ef33 100644 (file)
@@ -30,12 +30,11 @@ struct symbol {
 struct metric_result {
        struct metric *metric;                          /**< pointer to metric structure                        */
        double score;                                   /**< total score                                                        */
-       double required_score;                          /**< real required score                                        */
        double grow_factor;                                                             /**< current grow factor                                        */
        GHashTable *symbols;                            /**< symbols of metric                                          */
        GHashTable *sym_groups;                                                 /**< groups of symbols                                          */
-       gboolean checked;                               /**< whether metric result is consolidated  */
-       enum rspamd_metric_action action;                /**< the current action                                                */
+       gdouble actions_limits[METRIC_ACTION_MAX];              /**< set of actions for this metric                     */
+       enum rspamd_metric_action action;               /**< the current action                                         */
 };
 
 /**
index ef1c25b19cc3db503bfe5a0f113207b46ee0fdec..f949ca0a50e10c1d91854aac1771876b745d15cd 100644 (file)
@@ -802,7 +802,7 @@ rspamd_metric_result_ucl (struct rspamd_task *task,
 
        m = mres->metric;
        mres->action = rspamd_check_action_metric (task, mres->score,
-                                       &mres->required_score, m);
+                                       &mres->actions_limits[METRIC_ACTION_REJECT], m);
 
        action = mres->action;
        is_spam = (action < METRIC_ACTION_GREYLIST);
@@ -814,7 +814,7 @@ rspamd_metric_result_ucl (struct rspamd_task *task,
                "is_skipped", 0, false);
        ucl_object_insert_key (obj, ucl_object_fromdouble (mres->score),
                "score", 0, false);
-       ucl_object_insert_key (obj, ucl_object_fromdouble (mres->required_score),
+       ucl_object_insert_key (obj, ucl_object_fromdouble (mres->actions_limits[METRIC_ACTION_REJECT]),
                "required_score", 0, false);
        ucl_object_insert_key (obj,
                ucl_object_fromstring (rspamd_action_to_str (action)),
index cf26655f14c9f2eb85b7d7e6f6842c0e8ad4425b..8444d3fba57b382bb1822d6035696aa43920a96d 100644 (file)
@@ -821,7 +821,7 @@ rspamd_task_log_metric_res (struct rspamd_task *task,
                        break;
                case RSPAMD_LOG_SCORES:
                        res.len = rspamd_snprintf (scorebuf, sizeof (scorebuf), "%.2f/%.2f",
-                                       mres->score, mres->required_score);
+                                       mres->score, mres->actions_limits[METRIC_ACTION_REJECT]);
                        res.begin = scorebuf;
                        break;
                case RSPAMD_LOG_SYMBOLS:
index 1761dc7a33d9b9ff524b47102e8dd99fe97c94ae..2a40ca26c9ccf1abdc25b871253378cef49ccbd0 100644 (file)
@@ -735,7 +735,7 @@ rspamd_stat_check_autolearn (struct rspamd_task *task)
                                        if (mres) {
                                                mres->action = rspamd_check_action_metric (task,
                                                                mres->score,
-                                                               &mres->required_score,
+                                                               &mres->actions_limits[METRIC_ACTION_REJECT],
                                                                mres->metric);
 
                                                if (mres->action == METRIC_ACTION_REJECT) {