aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2020-05-08 23:55:51 +0200
committerKim Alvefur <zash@zash.se>2020-05-08 23:55:51 +0200
commita7c0def27f214441fe4881e119194540d291fd75 (patch)
treeaa68986ed5683800e12e6e125fae4a639084b565 /plugins
parent289898e68f98fe5edfb31ae622c9c3f0d6e1e039 (diff)
downloadprosody-a7c0def27f214441fe4881e119194540d291fd75.tar.gz
prosody-a7c0def27f214441fe4881e119194540d291fd75.zip
mod_s2s: Run stream close in async context
Allows async processing during stream shutdown. Fixes potential ASYNC-01 issues, however no such issues known at the time of this commit.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_s2s/mod_s2s.lua9
1 files changed, 8 insertions, 1 deletions
diff --git a/plugins/mod_s2s/mod_s2s.lua b/plugins/mod_s2s/mod_s2s.lua
index 2dad864c..9f7d4d6d 100644
--- a/plugins/mod_s2s/mod_s2s.lua
+++ b/plugins/mod_s2s/mod_s2s.lua
@@ -455,11 +455,16 @@ function stream_callbacks._streamopened(session, attr)
end
end
-function stream_callbacks.streamclosed(session)
+function stream_callbacks._streamclosed(session)
(session.log or log)("debug", "Received </stream:stream>");
session:close(false);
end
+function stream_callbacks.streamclosed(session, attr)
+ -- run _streamclosed in async context
+ session.thread:run({ stream = "closed", attr = attr });
+end
+
function stream_callbacks.error(session, error, data)
if error == "no-stream" then
session.log("debug", "Invalid opening stream header (%s)", (data:gsub("^([^\1]+)\1", "{%1}")));
@@ -568,6 +573,8 @@ local function initialize_session(session)
core_process_stanza(session, stanza);
elseif stanza.stream == "opened" then
stream_callbacks._streamopened(session, stanza.attr);
+ elseif stanza.stream == "closed" then
+ stream_callbacks._streamclosed(session, stanza.attr);
end
end, runner_callbacks, session);