diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-03-22 10:26:53 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-03-22 10:26:53 +0000 |
commit | 6c82b33813c0704e30902ef316236889cfc1f1a6 (patch) | |
tree | 4622b937ea6c2001507337cbef070bc04994efec /src | |
parent | 9384b6b83ffbe2ac85d57893a25da48261b033fb (diff) | |
download | rspamd-6c82b33813c0704e30902ef316236889cfc1f1a6.tar.gz rspamd-6c82b33813c0704e30902ef316236889cfc1f1a6.zip |
[Fix] Disable results caching
Diffstat (limited to 'src')
-rw-r--r-- | src/libserver/mempool_vars_internal.h | 1 | ||||
-rw-r--r-- | src/libserver/protocol.c | 79 | ||||
-rw-r--r-- | src/rspamd_proxy.c | 2 |
3 files changed, 7 insertions, 75 deletions
diff --git a/src/libserver/mempool_vars_internal.h b/src/libserver/mempool_vars_internal.h index 903f169f9..2f850a8ad 100644 --- a/src/libserver/mempool_vars_internal.h +++ b/src/libserver/mempool_vars_internal.h @@ -24,7 +24,6 @@ #define RSPAMD_MEMPOOL_SETTINGS_HASH "settings_hash" #define RSPAMD_MEMPOOL_MTA_TAG "MTA-Tag" #define RSPAMD_MEMPOOL_MTA_NAME "MTA-Name" -#define RSPAMD_MEMPOOL_CACHED_REPLY "cached_reply" #define RSPAMD_MEMPOOL_SPF_DOMAIN "spf_domain" #define RSPAMD_MEMPOOL_PRINCIPAL_RECIPIENT "principal_recipient" #define RSPAMD_MEMPOOL_PROFILE "profile" diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c index 103ad8588..752b4a674 100644 --- a/src/libserver/protocol.c +++ b/src/libserver/protocol.c @@ -1048,20 +1048,6 @@ rspamd_protocol_output_profiling (struct rspamd_task *task, ucl_object_insert_key (top, prof, "profile", 0, false); } -struct rspamd_saved_protocol_reply { - ucl_object_t *obj; - guint metric_changes; - enum rspamd_protocol_flags flags; -}; - -static void -rspamd_protocol_cached_dtor (gpointer p) -{ - struct rspamd_saved_protocol_reply *cached = p; - - ucl_object_unref (cached->obj); -} - ucl_object_t * rspamd_protocol_write_ucl (struct rspamd_task *task, enum rspamd_protocol_flags flags) @@ -1069,66 +1055,9 @@ rspamd_protocol_write_ucl (struct rspamd_task *task, ucl_object_t *top = NULL; GString *dkim_sig; const ucl_object_t *milter_reply; - struct rspamd_saved_protocol_reply *cached; - static const gchar *varname = RSPAMD_MEMPOOL_CACHED_REPLY; /* Check for cached reply */ - cached = rspamd_mempool_get_variable (task->task_pool, varname); - - if (cached) { - top = cached->obj; - /* - * Update flags: we don't need to set more flags than we need, - * so just xor previous flags and current flags and then or them - * to the cached one - */ - 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); - - /* We also set scan time here */ - task->time_real_finish = rspamd_get_ticks (FALSE); - task->time_virtual_finish = rspamd_get_virtual_ticks (); - } + top = ucl_object_typed_new (UCL_OBJECT); if (flags & RSPAMD_PROTOCOL_METRICS) { rspamd_metric_result_ucl (task, task->result, top); @@ -1213,8 +1142,8 @@ rspamd_protocol_write_ucl (struct rspamd_task *task, * space (ASCII 0x20) or tab (ASCII 0x09, or \t in C). * The line feed should NOT be preceded by a carriage return (ASCII 0x0d); * the MTA will add this automatically. - * It is the filter writer's responsibility to ensure that no s - * tandards are violated. + * It is the filter writer's responsibility to ensure that no + * standards are violated. */ ucl_object_insert_key (top, ucl_object_fromstring_common (folded_header->str, @@ -1678,6 +1607,8 @@ rspamd_protocol_write_reply (struct rspamd_task *task) case CMD_PROCESS: case CMD_SKIP: case CMD_CHECK_V2: + task->time_real_finish = rspamd_get_ticks (FALSE); + task->time_virtual_finish = rspamd_get_virtual_ticks (); rspamd_protocol_http_reply (msg, task, NULL); rspamd_protocol_write_log_pipe (task); break; diff --git a/src/rspamd_proxy.c b/src/rspamd_proxy.c index e3127f621..d19f769a1 100644 --- a/src/rspamd_proxy.c +++ b/src/rspamd_proxy.c @@ -1598,6 +1598,8 @@ rspamd_proxy_scan_self_reply (struct rspamd_task *task) case CMD_PROCESS: case CMD_SKIP: case CMD_CHECK_V2: + task->time_real_finish = rspamd_get_ticks (FALSE); + task->time_virtual_finish = rspamd_get_virtual_ticks (); rspamd_protocol_http_reply (msg, task, &rep); rspamd_protocol_write_log_pipe (task); break; |