# HG changeset patch # User Kim Alvefur <zash@zash.se> # Date 1626181474 -7200 # Node ID f90a337d81a886ceaa8655cbb697ff768179f28e # Parent 98bcc19361db002d1a9cf4b4b5adc7cb5674b7a2 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. diff -r 98bcc19361db -r f90a337d81a8 plugins/mod_s2s.lua --- 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