From: Vsevolod Stakhov Date: Mon, 8 Oct 2018 16:29:51 +0000 (+0100) Subject: [Minor] Update cached libevent time when possible X-Git-Tag: 1.8.1~68 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=074ef83168a4c06f1a4610e593ce7b45865d8450;p=rspamd.git [Minor] Update cached libevent time when possible --- 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);