commit 3241a8e: Revert "[Minor] Return to use of the monotonic timers"

Vsevolod Stakhov vsevolod at highsecure.ru
Fri May 3 17:42:03 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-05-03 18:34:29 +0100
URL: https://github.com/rspamd/rspamd/commit/3241a8e63b2aea5ee624b82d437e9d7bcce4bc1f

Revert "[Minor] Return to use of the monotonic timers"
This reverts commit baa142db22e670b1bc22dc785768141f0ecc1190.

---
 src/libserver/rspamd_symcache.c | 15 +++++++++++++++
 src/libserver/task.c            | 33 ++++++++++++++++++++++++++++++---
 2 files changed, 45 insertions(+), 3 deletions(-)

diff --git a/src/libserver/rspamd_symcache.c b/src/libserver/rspamd_symcache.c
index 3120dee47..c36a7e1d7 100644
--- a/src/libserver/rspamd_symcache.c
+++ b/src/libserver/rspamd_symcache.c
@@ -1444,7 +1444,15 @@ rspamd_symcache_check_symbol (struct rspamd_task *task,
 
 	if (check) {
 		msg_debug_cache_task ("execute %s, %d", item->symbol, item->id);
+#ifdef HAVE_EVENT_NO_CACHE_TIME_FUNC
+		struct timeval tv;
+
+		event_base_update_cache_time (task->ev_base);
+		event_base_gettimeofday_cached (task->ev_base, &tv);
+		t1 = tv_to_double (&tv);
+#else
 		t1 = rspamd_get_ticks (FALSE);
+#endif
 		dyn_item->start_msec = (t1 - task->time_real) * 1e3;
 		dyn_item->async_events = 0;
 		checkpoint->cur_item = item;
@@ -2707,7 +2715,14 @@ rspamd_symcache_finalize_item (struct rspamd_task *task,
 	checkpoint->items_inflight --;
 	checkpoint->cur_item = NULL;
 
+#ifdef HAVE_EVENT_NO_CACHE_TIME_FUNC
+	event_base_update_cache_time (task->ev_base);
+	event_base_gettimeofday_cached (task->ev_base, &tv);
+	t2 = tv_to_double (&tv);
+#else
 	t2 = rspamd_get_ticks (FALSE);
+#endif
+
 	diff = ((t2 - task->time_real) * 1e3 - dyn_item->start_msec);
 
 	if (G_UNLIKELY (RSPAMD_TASK_IS_PROFILING (task))) {
diff --git a/src/libserver/task.c b/src/libserver/task.c
index 1cabba221..d0ef40621 100644
--- a/src/libserver/task.c
+++ b/src/libserver/task.c
@@ -95,8 +95,20 @@ rspamd_task_new (struct rspamd_worker *worker, struct rspamd_config *cfg,
 
 	new_task->ev_base = ev_base;
 
-	new_task->time_real = rspamd_get_ticks (FALSE);
-	double_to_tv (new_task->time_real, &new_task->tv);
+#ifdef HAVE_EVENT_NO_CACHE_TIME_FUNC
+	if (ev_base) {
+		event_base_update_cache_time (ev_base);
+		event_base_gettimeofday_cached (ev_base, &new_task->tv);
+		new_task->time_real = tv_to_double (&new_task->tv);
+	}
+	else {
+		gettimeofday (&new_task->tv, NULL);
+		new_task->time_real = tv_to_double (&new_task->tv);
+	}
+#else
+	gettimeofday (&new_task->tv, NULL);
+	new_task->time_real = tv_to_double (&new_task->tv);
+#endif
 
 	new_task->time_virtual = rspamd_get_virtual_ticks ();
 	new_task->time_real_finish = NAN;
@@ -1686,9 +1698,24 @@ rspamd_task_profile_get (struct rspamd_task *task, const gchar *key)
 gboolean
 rspamd_task_set_finish_time (struct rspamd_task *task)
 {
+	struct timeval tv;
+
 	if (isnan (task->time_real_finish)) {
 
-		task->time_real_finish = rspamd_get_ticks (FALSE);
+#ifdef HAVE_EVENT_NO_CACHE_TIME_FUNC
+		if (task->ev_base) {
+			event_base_update_cache_time (task->ev_base);
+			event_base_gettimeofday_cached (task->ev_base, &tv);
+			task->time_real_finish = tv_to_double (&tv);
+		}
+		else {
+			gettimeofday (&tv, NULL);
+			task->time_real_finish = tv_to_double (&tv);
+		}
+#else
+		gettimeofday (&tv, NULL);
+		task->time_real_finish = tv_to_double (&tv);
+#endif
 		task->time_virtual_finish = rspamd_get_virtual_ticks ();
 
 		return TRUE;


More information about the Commits mailing list