Diff

plugins/mod_presence.lua @ 10813:4a9ff4f61796

mod_presence: Send unavailable presence in current thread run `session:dispatch_stanza(pres)` enqueues processing of the stanza in the sessions async thread, but becasue the entire stream close handling is now in that thread it would process the presence after the stream and session was completely closed, leading to weird errors "sent to a resting session". We call core_process_stanza() since this is what :dispatch_stanza calls in the end.
author Kim Alvefur <zash@zash.se>
date Sat, 09 May 2020 00:28:10 +0200
parent 10694:0cda5d597607
child 12977:74b9e05af71e
line wrap: on
line diff
--- a/plugins/mod_presence.lua	Sat May 09 00:07:42 2020 +0200
+++ b/plugins/mod_presence.lua	Sat May 09 00:28:10 2020 +0200
@@ -14,6 +14,7 @@
 local tonumber = tonumber;
 
 local core_post_stanza = prosody.core_post_stanza;
+local core_process_stanza = prosody.core_process_stanza;
 local st = require "util.stanza";
 local jid_split = require "util.jid".split;
 local jid_bare = require "util.jid".bare;
@@ -370,7 +371,7 @@
 		if err then
 			pres:tag("status"):text("Disconnected: "..err):up();
 		end
-		session:dispatch_stanza(pres);
+		core_process_stanza(session, pres);
 	elseif session.directed then
 		local pres = st.presence{ type = "unavailable", from = session.full_jid };
 		if err then