aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-10-08 17:29:51 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-10-08 17:31:43 +0100
commit074ef83168a4c06f1a4610e593ce7b45865d8450 (patch)
tree16b3dcf88ed6020a836378c9d364bf51745b76bc /src
parent9676fd5574bdccc88385d47437c081052adcfde5 (diff)
downloadrspamd-074ef83168a4c06f1a4610e593ce7b45865d8450.tar.gz
rspamd-074ef83168a4c06f1a4610e593ce7b45865d8450.zip
[Minor] Update cached libevent time when possible
Diffstat (limited to 'src')
-rw-r--r--src/libserver/symbols_cache.c20
-rw-r--r--src/lua/lua_config.c5
2 files changed, 24 insertions, 1 deletions
diff --git a/src/libserver/symbols_cache.c b/src/libserver/symbols_cache.c
index 8558d62e5..0bd90ec70 100644
--- a/src/libserver/symbols_cache.c
+++ b/src/libserver/symbols_cache.c
@@ -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))) {
diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c
index 32796fb01..c4d71b8ca 100644
--- a/src/lua/lua_config.c
+++ b/src/lua/lua_config.c
@@ -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);