commit 4b44896: [Project] Process composites separately for each shadow result
Vsevolod Stakhov
vsevolod at highsecure.ru
Wed Apr 8 13:21:06 UTC 2020
Author: Vsevolod Stakhov
Date: 2020-04-08 14:09:12 +0100
URL: https://github.com/rspamd/rspamd/commit/4b448965ed4611ac6c44ab66a602b75c088bdc96
[Project] Process composites separately for each shadow result
---
src/libserver/composites.c | 23 +++++++++++++++--------
src/libserver/composites.h | 2 +-
src/libserver/task.c | 4 ++--
3 files changed, 18 insertions(+), 11 deletions(-)
diff --git a/src/libserver/composites.c b/src/libserver/composites.c
index c35ba2431..04b0a4ef8 100644
--- a/src/libserver/composites.c
+++ b/src/libserver/composites.c
@@ -201,7 +201,7 @@ rspamd_composite_process_single_symbol (struct composites_data *cd,
struct rspamd_composite *ncomp;
struct rspamd_task *task = cd->task;
- if ((ms = rspamd_task_find_symbol_result (cd->task, sym, NULL)) == NULL) {
+ if ((ms = rspamd_task_find_symbol_result (cd->task, sym, cd->metric_res)) == NULL) {
msg_debug_composites ("not found symbol %s in composite %s", sym,
cd->composite->sym);
if ((ncomp =
@@ -225,14 +225,16 @@ rspamd_composite_process_single_symbol (struct composites_data *cd,
cd->composite = saved;
clrbit (cd->checked, cd->composite->id * 2);
- ms = rspamd_task_find_symbol_result (cd->task, sym, NULL);
+ ms = rspamd_task_find_symbol_result (cd->task, sym,
+ cd->metric_res);
}
else {
/*
* XXX: in case of cyclic references this would return 0
*/
if (isset (cd->checked, ncomp->id * 2 + 1)) {
- ms = rspamd_task_find_symbol_result (cd->task, sym, NULL);
+ ms = rspamd_task_find_symbol_result (cd->task, sym,
+ cd->metric_res);
}
}
}
@@ -396,7 +398,7 @@ rspamd_composite_expr_process (void *ud,
if (isset (cd->checked, cd->composite->id * 2)) {
/* We have already checked this composite, so just return its value */
if (isset (cd->checked, cd->composite->id * 2 + 1)) {
- ms = rspamd_task_find_symbol_result (cd->task, sym, NULL);
+ ms = rspamd_task_find_symbol_result (cd->task, sym, cd->metric_res);
}
if (ms) {
@@ -563,7 +565,8 @@ composites_foreach_callback (gpointer key, gpointer value, void *data)
clrbit (cd->checked, comp->id * 2 + 1);
}
else {
- if (rspamd_task_find_symbol_result (cd->task, key, NULL) != NULL) {
+ if (rspamd_task_find_symbol_result (cd->task, key,
+ cd->metric_res) != NULL) {
/* Already set, no need to check */
msg_debug_composites ("composite %s is already in metric "
"in composites bitfield", cd->composite->sym);
@@ -652,7 +655,7 @@ composites_remove_symbols (gpointer key, gpointer value, gpointer data)
}
}
- ms = rspamd_task_find_symbol_result (task, rd->sym, NULL);
+ ms = rspamd_task_find_symbol_result (task, rd->sym, cd->metric_res);
if (has_valid_op && ms && !(ms->flags & RSPAMD_SYMBOL_RESULT_IGNORED)) {
@@ -697,10 +700,14 @@ composites_metric_callback (struct rspamd_scan_result *metric_res,
}
void
-rspamd_make_composites (struct rspamd_task *task)
+rspamd_composites_process_task (struct rspamd_task *task)
{
if (task->result && !RSPAMD_TASK_IS_SKIPPED (task)) {
- composites_metric_callback (task->result, task);
+ struct rspamd_scan_result *mres;
+
+ DL_FOREACH (task->result, mres) {
+ composites_metric_callback (mres, task);
+ }
}
}
diff --git a/src/libserver/composites.h b/src/libserver/composites.h
index d9947a7dd..bb7eb8994 100644
--- a/src/libserver/composites.h
+++ b/src/libserver/composites.h
@@ -52,7 +52,7 @@ struct rspamd_composite {
* Process all results and form composite metrics from existent metrics as it is defined in config
* @param task worker's task that present message from user
*/
-void rspamd_make_composites (struct rspamd_task *task);
+void rspamd_composites_process_task (struct rspamd_task *task);
enum rspamd_composite_policy rspamd_composite_policy_from_str (const gchar *string);
diff --git a/src/libserver/task.c b/src/libserver/task.c
index a0d7bb12a..30ba0f195 100644
--- a/src/libserver/task.c
+++ b/src/libserver/task.c
@@ -748,7 +748,7 @@ rspamd_task_process (struct rspamd_task *task, guint stages)
break;
case RSPAMD_TASK_STAGE_COMPOSITES:
- rspamd_make_composites (task);
+ rspamd_composites_process_task (task);
break;
case RSPAMD_TASK_STAGE_POST_FILTERS:
@@ -807,7 +807,7 @@ rspamd_task_process (struct rspamd_task *task, guint stages)
break;
case RSPAMD_TASK_STAGE_COMPOSITES_POST:
/* Second run of composites processing before idempotent filters */
- rspamd_make_composites (task);
+ rspamd_composites_process_task (task);
break;
case RSPAMD_TASK_STAGE_IDEMPOTENT:
More information about the Commits
mailing list