From: Vsevolod Stakhov Date: Tue, 23 Sep 2014 15:51:05 +0000 (+0100) Subject: Rework pre-filters results processing. X-Git-Tag: 0.7.1~9 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a59114820efe8abfc606da71b8e94c1759ceedab;p=rspamd.git Rework pre-filters results processing. --- diff --git a/src/libmime/filter.c b/src/libmime/filter.c index 6ae51f769..540502a47 100644 --- a/src/libmime/filter.c +++ b/src/libmime/filter.c @@ -93,6 +93,7 @@ rspamd_create_metric_result (struct rspamd_task *task, const gchar *name) metric_res->score = 0; g_hash_table_insert (task->results, (gpointer) metric->name, metric_res); + metric_res->action = METRIC_ACTION_MAX; return metric_res; } diff --git a/src/libmime/filter.h b/src/libmime/filter.h index 69c20bdd1..3f01f2314 100644 --- a/src/libmime/filter.h +++ b/src/libmime/filter.h @@ -65,6 +65,7 @@ struct metric { struct metric_result { struct metric *metric; /**< pointer to metric structure */ double score; /**< total score */ + enum rspamd_metric_action action; /**< the current action */ GHashTable *symbols; /**< symbols of metric */ gboolean checked; /**< whether metric result is consolidated */ double grow_factor; /**< current grow factor */ diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c index 9ecb3c642..7dadc65ec 100644 --- a/src/libserver/protocol.c +++ b/src/libserver/protocol.c @@ -648,8 +648,16 @@ rspamd_metric_result_ucl (struct rspamd_task *task, m = mres->metric; /* XXX: handle settings */ - action = rspamd_check_action_metric (task, mres->score, &required_score, m); + if (mres->action == METRIC_ACTION_MAX) { + mres->action = rspamd_check_action_metric (task, mres->score, + &required_score, m); + } + else { + required_score = mres->metric->actions[mres->action].score; + } + action = mres->action; is_spam = (action == METRIC_ACTION_REJECT); + if (task->is_skipped) { action_char = 'S'; } @@ -659,6 +667,7 @@ rspamd_metric_result_ucl (struct rspamd_task *task, else { action_char = 'F'; } + rspamd_printf_gstring (logbuf, "(%s: %c (%s): [%.2f/%.2f] [", m->name, action_char, rspamd_action_to_str (action), @@ -790,7 +799,6 @@ rspamd_protocol_http_reply (struct rspamd_http_message *msg, rspamd_http_message_add_header (msg, hn->str, hv->str); } - g_hash_table_iter_init (&hiter, task->results); top = ucl_object_typed_new (UCL_OBJECT); diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c index d91774d1b..cb0d7325b 100644 --- a/src/lua/lua_task.c +++ b/src/lua/lua_task.c @@ -793,6 +793,7 @@ lua_task_set_pre_result (lua_State * L) mres = rspamd_create_metric_result (task, DEFAULT_METRIC); if (mres != NULL) { mres->score = mres->metric->actions[action].score; + mres->action = action; } task->pre_result.action = action; if (lua_gettop (L) >= 3) {