Software /
code /
prosody
Changeset
10810:8a0a923e1ced
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.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 08 May 2020 23:55:51 +0200 |
parents | 10809:86ea811ee25b |
children | 10811:16bcbd574801 |
files | plugins/mod_s2s/mod_s2s.lua |
diffstat | 1 files changed, 8 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_s2s/mod_s2s.lua Fri May 08 23:54:17 2020 +0200 +++ b/plugins/mod_s2s/mod_s2s.lua Fri May 08 23:55:51 2020 +0200 @@ -455,11 +455,16 @@ 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 @@ 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);