aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-03-03 13:34:00 +0100
committerKim Alvefur <zash@zash.se>2021-03-03 13:34:00 +0100
commit8673a99a09f5e18537ffca296c48e0c94451fc16 (patch)
treedb4d6da2ddffef231ecafa16bfac76cd9e8969bc
parente78947232736427aa6305f4c773e68cbeba63c59 (diff)
downloadprosody-8673a99a09f5e18537ffca296c48e0c94451fc16.tar.gz
prosody-8673a99a09f5e18537ffca296c48e0c94451fc16.zip
mod_s2s: Buffer stream error + stream closing tag
In "opportunistic writes" mode, prevents ondisconnect from happening while writing the stream closing tag.
-rw-r--r--plugins/mod_s2s.lua5
1 files changed, 4 insertions, 1 deletions
diff --git a/plugins/mod_s2s.lua b/plugins/mod_s2s.lua
index 3d4506bf..4115bca6 100644
--- a/plugins/mod_s2s.lua
+++ b/plugins/mod_s2s.lua
@@ -503,6 +503,8 @@ local stream_xmlns_attr = {xmlns='urn:ietf:params:xml:ns:xmpp-streams'};
local function session_close(session, reason, remote_reason, bounce_reason)
local log = session.log or log;
if session.conn then
+ local conn = session.conn;
+ conn:pause_writes(); -- until :close
if session.notopen then
if session.direction == "incoming" then
session:open_stream(session.to_host, session.from_host);
@@ -540,8 +542,9 @@ local function session_close(session, reason, remote_reason, bounce_reason)
session.log("info", "%s s2s stream %s->%s closed: %s", session.direction:gsub("^.", string.upper),
session.from_host or "(unknown host)", session.to_host or "(unknown host)", reason or "stream closed");
+ conn:resume_writes();
+
-- Authenticated incoming stream may still be sending us stanzas, so wait for </stream:stream> from remote
- local conn = session.conn;
if reason == nil and not session.notopen and session.direction == "incoming" then
add_task(stream_close_timeout, function ()
if not session.destroyed then