commit a14f280: [Minor] Try to fix brain damaged libev timers

Vsevolod Stakhov vsevolod at highsecure.ru
Mon Mar 16 11:49:10 UTC 2020


Author: Vsevolod Stakhov
Date: 2020-03-16 11:32:49 +0000
URL: https://github.com/rspamd/rspamd/commit/a14f2804072416d77a8e2ad44292ceb41b81966a

[Minor] Try to fix brain damaged libev timers

---
 src/libserver/fuzzy_backend/fuzzy_backend_redis.c | 6 ++++++
 src/lua/lua_redis.c                               | 1 +
 2 files changed, 7 insertions(+)

diff --git a/src/libserver/fuzzy_backend/fuzzy_backend_redis.c b/src/libserver/fuzzy_backend/fuzzy_backend_redis.c
index 32f03cfe2..3574a63bf 100644
--- a/src/libserver/fuzzy_backend/fuzzy_backend_redis.c
+++ b/src/libserver/fuzzy_backend/fuzzy_backend_redis.c
@@ -420,6 +420,7 @@ rspamd_fuzzy_redis_shingles_callback (redisAsyncContext *c, gpointer r,
 					else {
 						/* Add timeout */
 						session->timeout.data = session;
+						ev_now_update_if_cheap ((struct ev_loop *)session->event_loop);
 						ev_timer_init (&session->timeout,
 								rspamd_fuzzy_redis_timeout,
 								session->backend->timeout, 0.0);
@@ -500,6 +501,7 @@ rspamd_fuzzy_backend_check_shingles (struct rspamd_fuzzy_redis_session *session)
 	else {
 		/* Add timeout */
 		session->timeout.data = session;
+		ev_now_update_if_cheap ((struct ev_loop *)session->event_loop);
 		ev_timer_init (&session->timeout,
 				rspamd_fuzzy_redis_timeout,
 				session->backend->timeout, 0.0);
@@ -677,6 +679,7 @@ rspamd_fuzzy_backend_check_redis (struct rspamd_fuzzy_backend *bk,
 		else {
 			/* Add timeout */
 			session->timeout.data = session;
+			ev_now_update_if_cheap ((struct ev_loop *)session->event_loop);
 			ev_timer_init (&session->timeout,
 					rspamd_fuzzy_redis_timeout,
 					session->backend->timeout, 0.0);
@@ -802,6 +805,7 @@ rspamd_fuzzy_backend_count_redis (struct rspamd_fuzzy_backend *bk,
 		else {
 			/* Add timeout */
 			session->timeout.data = session;
+			ev_now_update_if_cheap ((struct ev_loop *)session->event_loop);
 			ev_timer_init (&session->timeout,
 					rspamd_fuzzy_redis_timeout,
 					session->backend->timeout, 0.0);
@@ -928,6 +932,7 @@ rspamd_fuzzy_backend_version_redis (struct rspamd_fuzzy_backend *bk,
 		else {
 			/* Add timeout */
 			session->timeout.data = session;
+			ev_now_update_if_cheap ((struct ev_loop *)session->event_loop);
 			ev_timer_init (&session->timeout,
 					rspamd_fuzzy_redis_timeout,
 					session->backend->timeout, 0.0);
@@ -1554,6 +1559,7 @@ rspamd_fuzzy_backend_update_redis (struct rspamd_fuzzy_backend *bk,
 		else {
 			/* Add timeout */
 			session->timeout.data = session;
+			ev_now_update_if_cheap ((struct ev_loop *)session->event_loop);
 			ev_timer_init (&session->timeout,
 					rspamd_fuzzy_redis_timeout,
 					session->backend->timeout, 0.0);
diff --git a/src/lua/lua_redis.c b/src/lua/lua_redis.c
index 24d30964f..f9dbbdd13 100644
--- a/src/lua/lua_redis.c
+++ b/src/lua/lua_redis.c
@@ -1126,6 +1126,7 @@ lua_redis_make_request (lua_State *L)
 			REDIS_RETAIN (ctx); /* Cleared by fin event */
 			ctx->cmds_pending ++;
 			sp_ud->timeout_ev.data = sp_ud;
+			ev_now_update_if_cheap ((struct ev_loop *)ud->event_loop);
 			ev_timer_init (&sp_ud->timeout_ev, lua_redis_timeout, timeout, 0.0);
 			ev_timer_start (ud->event_loop, &sp_ud->timeout_ev);
 			ret = TRUE;


More information about the Commits mailing list