]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Fix] Fix scan time set
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 22 Mar 2018 15:18:49 +0000 (15:18 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 22 Mar 2018 15:32:33 +0000 (15:32 +0000)
src/libserver/protocol.c
src/libserver/task.c
src/libserver/task.h
src/rspamd_proxy.c

index 752b4a6743ab73107dc9ca581814f4bfcdf8c3cc..6662bf677baaed2632de92a52d31805b1b243de4 100644 (file)
@@ -1056,7 +1056,7 @@ rspamd_protocol_write_ucl (struct rspamd_task *task,
        GString *dkim_sig;
        const ucl_object_t *milter_reply;
 
-       /* Check for cached reply */
+       rspamd_task_set_finish_time (task);
        top = ucl_object_typed_new (UCL_OBJECT);
 
        if (flags & RSPAMD_PROTOCOL_METRICS) {
@@ -1607,8 +1607,6 @@ 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;
index 71e38ed4c721c2f1497f8077a0056a449f299d36..e723fd9556d9e9fd476060d45b34525e6d4dc72c 100644 (file)
@@ -84,6 +84,8 @@ rspamd_task_new (struct rspamd_worker *worker, struct rspamd_config *cfg,
        gettimeofday (&new_task->tv, NULL);
        new_task->time_real = rspamd_get_ticks (FALSE);
        new_task->time_virtual = rspamd_get_virtual_ticks ();
+       new_task->time_real_finish = NAN;
+       new_task->time_virtual_finish = NAN;
        new_task->lang_det = lang_det;
 
        if (pool == NULL) {
@@ -1594,3 +1596,17 @@ rspamd_task_profile_get (struct rspamd_task *task, const gchar *key)
 
        return pval;
 }
+
+
+gboolean
+rspamd_task_set_finish_time (struct rspamd_task *task)
+{
+       if (isnan (task->time_real_finish)) {
+               task->time_real_finish = rspamd_get_ticks (FALSE);
+               task->time_virtual_finish = rspamd_get_virtual_ticks ();
+
+               return TRUE;
+       }
+
+       return FALSE;
+}
\ No newline at end of file
index 3055c5654046eac79d0a8d1ec55117d247c3420b..b6ff2799073cfc640885205d52ff4b358d9573cd 100644 (file)
@@ -347,4 +347,11 @@ void rspamd_task_profile_set (struct rspamd_task *task, const gchar *key,
  */
 gdouble* rspamd_task_profile_get (struct rspamd_task *task, const gchar *key);
 
+/**
+ * Sets finishing time for a task if not yet set
+ * @param task
+ * @return
+ */
+gboolean rspamd_task_set_finish_time (struct rspamd_task *task);
+
 #endif /* TASK_H_ */
index d19f769a1be9515da2fdc3fe21ad94f278915e6b..47dbf606dadee457446cf721f9466a6e127be717 100644 (file)
@@ -1598,8 +1598,7 @@ 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_task_set_finish_time (task);
                rspamd_protocol_http_reply (msg, task, &rep);
                rspamd_protocol_write_log_pipe (task);
                break;