aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua/lua_tcp.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2024-12-10 18:55:09 +0600
committerGitHub <noreply@github.com>2024-12-10 18:55:09 +0600
commit4c978e0512acc7793a88ea9fa0388e847d9faff5 (patch)
tree724e60332ba97a900fcadcdf47363da7254b09d4 /src/lua/lua_tcp.c
parent3e033c74c80913707c45451892cfcf9b5ed98c83 (diff)
parent2b2b2762cc48f6be7a26c185bd95e7c77cdc46fa (diff)
downloadrspamd-4c978e0512acc7793a88ea9fa0388e847d9faff5.tar.gz
rspamd-4c978e0512acc7793a88ea9fa0388e847d9faff5.zip
Merge pull request #5251 from rspamd/vstakhov-cumulative-tcp-timeout
[Fix] Use cumulative timeout when dealing with TCP connections
Diffstat (limited to 'src/lua/lua_tcp.c')
-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) {