commit a35e93d: [Fix] Another try to fix slow callbacks and timers
Vsevolod Stakhov
vsevolod at highsecure.ru
Thu Oct 31 12:35:07 UTC 2019
Author: Vsevolod Stakhov
Date: 2019-10-31 12:30:49 +0000
URL: https://github.com/rspamd/rspamd/commit/a35e93dc39223107941a5b31ed6d0191e27777b4 (HEAD -> master)
[Fix] Another try to fix slow callbacks and timers
---
src/libutil/libev_helper.c | 6 ++++++
src/lua/lua_http.c | 3 ---
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/libutil/libev_helper.c b/src/libutil/libev_helper.c
index 65a53d3f7..41195bfa6 100644
--- a/src/libutil/libev_helper.c
+++ b/src/libutil/libev_helper.c
@@ -70,6 +70,9 @@ rspamd_ev_watcher_start (struct ev_loop *loop,
ev_io_start (EV_A_ &ev->io);
if (timeout > 0) {
+ /* Update timestamp to avoid timers running early */
+ ev_now_update (loop);
+
ev->timeout = timeout;
ev_timer_set (&ev->tm, timeout, 0.0);
ev_timer_start (EV_A_ &ev->tm);
@@ -109,6 +112,9 @@ rspamd_ev_watcher_reschedule (struct ev_loop *loop,
if (ev->timeout > 0) {
if (!(ev_can_stop (&ev->tm))) {
+ /* Update timestamp to avoid timers running early */
+ ev_now_update (loop);
+
ev->tm.data = ev;
ev_timer_init (&ev->tm, rspamd_ev_watcher_timer_cb, ev->timeout, 0.0);
ev_timer_start (EV_A_ &ev->tm);
diff --git a/src/lua/lua_http.c b/src/lua/lua_http.c
index 76c0c9055..9a3238364 100644
--- a/src/lua/lua_http.c
+++ b/src/lua/lua_http.c
@@ -391,9 +391,6 @@ lua_http_make_connection (struct lua_http_cbdata *cbd)
if (cbd->flags & RSPAMD_LUA_HTTP_FLAG_KEEP_ALIVE) {
cbd->fd = -1; /* FD is owned by keepalive connection */
-
- /* Update timestamp to make a more precise timers */
- ev_now_update (cbd->event_loop);
cbd->conn = rspamd_http_connection_new_keepalive (
NULL, /* Default context */
NULL,
More information about the Commits
mailing list