diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-12-09 12:49:19 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-12-09 12:49:19 +0000 |
commit | 2b2b2762cc48f6be7a26c185bd95e7c77cdc46fa (patch) | |
tree | 698339cccacd6ca84182975df8bd1231bb50595f /src/lua/lua_tcp.c | |
parent | eecb96c9eb45f6b6a8d66b4c3462c2d1a2371985 (diff) | |
download | rspamd-vstakhov-cumulative-tcp-timeout.tar.gz rspamd-vstakhov-cumulative-tcp-timeout.zip |
[Fix] Use cumulative timeout when dealing with TCP connectionsvstakhov-cumulative-tcp-timeout
Diffstat (limited to 'src/lua/lua_tcp.c')
-rw-r--r-- | src/lua/lua_tcp.c | 8 |
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) { |