aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver/protocol.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-08-05 23:08:18 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-08-05 23:08:18 +0100
commit9632c62a868e9086c5a016eb6b259ffe6f233770 (patch)
tree6bc77bac35d7a78c7573ae010a0c47b4045f5662 /src/libserver/protocol.c
parent76a11f2feb1be9d7f8940ab6a77be04a222ee81d (diff)
downloadrspamd-9632c62a868e9086c5a016eb6b259ffe6f233770.tar.gz
rspamd-9632c62a868e9086c5a016eb6b259ffe6f233770.zip
[Feature] Allow to use postfilters in composites
We actually process composites twice now so it somehow slows down processing by extra hash lookup. Additional logic to regenerate metric reply if something is changed by this extra run of composites is also added. Issue: #1726
Diffstat (limited to 'src/libserver/protocol.c')
-rw-r--r--src/libserver/protocol.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c
index 6ccb83229..93ea62816 100644
--- a/src/libserver/protocol.c
+++ b/src/libserver/protocol.c
@@ -1067,6 +1067,7 @@ rspamd_protocol_output_profiling (struct rspamd_task *task,
struct rspamd_saved_protocol_reply {
ucl_object_t *obj;
+ guint metric_changes;
enum rspamd_protocol_flags flags;
};
@@ -1101,12 +1102,43 @@ rspamd_protocol_write_ucl (struct rspamd_task *task,
flags ^= cached->flags;
cached->flags |= flags;
+ if (task->result &&
+ cached->metric_changes != task->result->changes) {
+ msg_info_task ("found metric modifications (%d) before we have "
+ "generated protocol results (%d), regenerate them",
+ task->result->changes, cached->metric_changes);
+
+ flags |= RSPAMD_PROTOCOL_METRICS;
+
+ if (task->cmd == CMD_CHECK_V2) {
+ ucl_object_delete_key (top, "symbols");
+ }
+ else {
+ ucl_object_delete_key (top, DEFAULT_METRIC);
+ }
+
+ /* That all is related to metric unfortunately */
+ ucl_object_delete_key (top, "is_spam");
+ ucl_object_delete_key (top, "is_skipped");
+ ucl_object_delete_key (top, "score");
+ ucl_object_delete_key (top, "required_score");
+ ucl_object_delete_key (top, "action");
+ ucl_object_delete_key (top, "subject");
+ }
+ if (task->result) {
+ cached->metric_changes = task->result->changes;
+ }
}
else {
top = ucl_object_typed_new (UCL_OBJECT);
cached = rspamd_mempool_alloc (task->task_pool, sizeof (*cached));
cached->obj = top;
cached->flags = flags;
+
+ if (task->result) {
+ cached->metric_changes = task->result->changes;
+ }
+
rspamd_mempool_set_variable (task->task_pool, varname,
cached, rspamd_protocol_cached_dtor);