comparison core/s2smanager.lua @ 13987:4067a95336dd

mod_s2s, s2smanager: Experimental s2s_block_immediate_retries option Currently, if Prosody fails to connect to a remote domain, any pending stanzas are bounced back to the sender. If the code processing these stanzas responds to the error, we will begin a new outgoing connection before we've even finished processing the last one. This generally hasn't been a problem, Prosody handles it fine. However, it is questionable whether this is sensible behaviour (if we *just* failed to connect, will an immediate retry even work most of the time?). It can also lead to some awkward traffic patterns, e.g. when combined with MUC. For example, when a MUC receives an error from a remote user, it may kick that user from the MUC. This will cause a stanza to be sent to everyone else in the MUC. If other users from the same domain are present, the notification will be sent to the remote domain, triggering a new connection attempt for no reason (the user was likely about to be kicked anyway after the sendq had finished being bounced). This new option enables an alternative strategy, where attempts to send to the remote domain that failed will be rejected until the sendq has finished being processed. To enable the new behaviour, set the global option: s2s_block_immediate_retries = true
author Matthew Wild <mwild1@gmail.com>
date Thu, 16 Oct 2025 18:29:03 +0100
parents ead41e25ebc0
children
comparison
equal deleted inserted replaced
13986:107a3d9c147b 13987:4067a95336dd
89 if session.destroyed then return; end 89 if session.destroyed then return; end
90 local log = session.log or log; 90 local log = session.log or log;
91 log("debug", "Destroying %s session %s->%s%s%s", session.direction, session.from_host, session.to_host, reason and ": " or "", reason or ""); 91 log("debug", "Destroying %s session %s->%s%s%s", session.direction, session.from_host, session.to_host, reason and ": " or "", reason or "");
92 92
93 if session.direction == "outgoing" then 93 if session.direction == "outgoing" then
94 hosts[session.from_host].s2sout[session.to_host] = nil; 94 if session.block_retries then
95 session:bounce_sendq(bounce_reason or reason); 95 -- Reject any attempts to communicate with the failed domain
96 -- while we are bouncing the stanzas
97 session.send = function () return false; end
98 session.sends2s = function () return false; end
99 session:bounce_sendq(bounce_reason or reason);
100 hosts[session.from_host].s2sout[session.to_host] = nil;
101 else
102 hosts[session.from_host].s2sout[session.to_host] = nil;
103 session:bounce_sendq(bounce_reason or reason);
104 end
96 elseif session.direction == "incoming" then 105 elseif session.direction == "incoming" then
97 if session.outgoing and hosts[session.to_host].s2sout[session.from_host] == session then 106 if session.outgoing and hosts[session.to_host].s2sout[session.from_host] == session then
98 hosts[session.to_host].s2sout[session.from_host] = nil; 107 hosts[session.to_host].s2sout[session.from_host] = nil;
99 end 108 end
100 incoming_s2s[session] = nil; 109 incoming_s2s[session] = nil;