Software /
code /
prosody
Diff
plugins/mod_s2s.lua @ 11678:f90a337d81a8
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.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 13 Jul 2021 15:04:34 +0200 |
parent | 11670:7f6c816a2c09 |
child | 11682:7843f1ca3b33 |
line wrap: on
line diff
--- a/plugins/mod_s2s.lua Tue Jul 13 14:58:50 2021 +0200 +++ b/plugins/mod_s2s.lua Tue Jul 13 15:04:34 2021 +0200 @@ -17,6 +17,7 @@ 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 @@ 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 @@ 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 @@ 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