diff options
author | Kim Alvefur <zash@zash.se> | 2021-07-13 15:04:34 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2021-07-13 15:04:34 +0200 |
commit | 0ea107ffd060dbc1b3926e29ead3f24ce2ca6ab2 (patch) | |
tree | f7884ecfe32c5767ca546272ef9422ad991bfc57 | |
parent | 357cf7647a4e3c98cab0046e8342e23501e278f4 (diff) | |
download | prosody-0ea107ffd060dbc1b3926e29ead3f24ce2ca6ab2.tar.gz prosody-0ea107ffd060dbc1b3926e29ead3f24ce2ca6ab2.zip |
mod_s2s: Remove connection timeout once it's no longer needed
Reduces the number of left-over timers to handle after many s2s
connections were started, leaving only the ones related to incomplete
connections.
-rw-r--r-- | plugins/mod_s2s.lua | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/plugins/mod_s2s.lua b/plugins/mod_s2s.lua index 217797df..f673e9c5 100644 --- a/plugins/mod_s2s.lua +++ b/plugins/mod_s2s.lua @@ -17,6 +17,7 @@ local t_insert = table.insert; local traceback = debug.traceback; local add_task = require "util.timer".add_task; +local stop_timer = require "util.timer".stop; local st = require "util.stanza"; local initialize_filters = require "util.filters".initialize; local nameprep = require "util.encodings".stringprep.nameprep; @@ -305,6 +306,11 @@ function mark_connected(session) session.sendq = nil; end end + + if session.connect_timeout then + stop_timer(session.connect_timeout); + session.connect_timeout = nil; + end end function make_authenticated(event) @@ -612,6 +618,11 @@ local function session_close(session, reason, remote_reason, bounce_reason) conn:resume_writes(); + if session.connect_timeout then + stop_timer(session.connect_timeout); + session.connect_timeout = nil; + end + -- Authenticated incoming stream may still be sending us stanzas, so wait for </stream:stream> from remote if reason == nil and not session.notopen and session.direction == "incoming" then add_task(stream_close_timeout, function () @@ -706,7 +717,7 @@ local function initialize_session(session) module:fire_event("s2s-created", { session = session }); - add_task(connect_timeout, function () + session.connect_timeout = add_task(connect_timeout, function () if session.type == "s2sin" or session.type == "s2sout" then return; -- Ok, we're connected elseif session.type == "s2s_destroyed" then |