aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua
diff options
context:
space:
mode:
Diffstat (limited to 'src/lua')
-rw-r--r--src/lua/lua_tcp.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/lua/lua_tcp.c b/src/lua/lua_tcp.c
index f498f9598..bea8d2ef9 100644
--- a/src/lua/lua_tcp.c
+++ b/src/lua/lua_tcp.c
@@ -1099,11 +1099,17 @@ lua_tcp_handler(int fd, short what, gpointer ud)
TCP_RETAIN(cbd);
msg_debug_tcp("processed TCP event: %d", what);
+ ev_tstamp elapsed;
struct lua_tcp_handler *rh = g_queue_peek_head(cbd->handlers);
event_type = rh->type;
- rspamd_ev_watcher_stop(cbd->event_loop, &cbd->ev);
+ elapsed = rspamd_ev_watcher_stop(cbd->event_loop, &cbd->ev);
+
+ /* Adjust timeout, as we have already spent time */
+ if (elapsed > 0 && elapsed < cbd->ev.timeout) {
+ cbd->ev.timeout -= elapsed;
+ }
if (what == EV_READ) {
if (cbd->ssl_conn) {