]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Update cached libevent time when possible
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 8 Oct 2018 16:29:51 +0000 (17:29 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 8 Oct 2018 16:31:43 +0000 (17:31 +0100)
src/libserver/symbols_cache.c
src/lua/lua_config.c

index 8558d62e5eb086d3c95e910d38bbf1ccc9bed3cc..0bd90ec7069156ad5ea879ac92cc614f42f0bf43 100644 (file)
@@ -1303,6 +1303,9 @@ rspamd_symbols_cache_watcher_cb (gpointer sessiond, gpointer ud)
        setbit (checkpoint->processed_bits, item->id * 2 + 1);
 
        if (checkpoint->pass > 0) {
+#ifdef HAVE_EVENT_NO_CACHE_TIME_FUNC
+               event_base_update_cache_time (task->ev_base);
+#endif
                for (i = 0; i < (gint)checkpoint->waitq->len; i ++) {
                        it = g_ptr_array_index (checkpoint->waitq, i);
 
@@ -1382,9 +1385,26 @@ rspamd_symbols_cache_check_symbol (struct rspamd_task *task,
                                        rspamd_symbols_cache_watcher_cb,
                                        item);
                        msg_debug_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
+
                        item->func (task, item->user_data);
+
+#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 - t1);
 
                        if (G_UNLIKELY (RSPAMD_TASK_IS_PROFILING (task))) {
index 32796fb01a73eb25926fcd9d72f79b69a4c4fba9..c4d71b8ca43238be0ee9fd687d4b26379cc01314 100644 (file)
@@ -2873,7 +2873,6 @@ lua_periodic_callback (gint unused_fd, short what, gpointer ud)
        *pev_base = periodic->ev_base;
 
        event_del (&periodic->ev);
-
        lua_thread_call (thread, 2);
 }
 
@@ -2888,6 +2887,10 @@ lua_periodic_callback_finish (struct thread_entry *thread, int ret)
 
        L = thread->lua_state;
 
+#ifdef HAVE_EVENT_NO_CACHE_TIME_FUNC
+       event_base_update_cache_time (periodic->ev_base);
+#else
+
        if (ret == 0) {
                if (lua_type (L, -1) == LUA_TBOOLEAN) {
                        plan_more = lua_toboolean (L, -1);