Software /
code /
prosody
Comparison
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 |
comparison
equal
deleted
inserted
replaced
10812:3bd846c76701 | 10813:4a9ff4f61796 |
---|---|
12 local pairs = pairs; | 12 local pairs = pairs; |
13 local s_find = string.find; | 13 local s_find = string.find; |
14 local tonumber = tonumber; | 14 local tonumber = tonumber; |
15 | 15 |
16 local core_post_stanza = prosody.core_post_stanza; | 16 local core_post_stanza = prosody.core_post_stanza; |
17 local core_process_stanza = prosody.core_process_stanza; | |
17 local st = require "util.stanza"; | 18 local st = require "util.stanza"; |
18 local jid_split = require "util.jid".split; | 19 local jid_split = require "util.jid".split; |
19 local jid_bare = require "util.jid".bare; | 20 local jid_bare = require "util.jid".bare; |
20 local datetime = require "util.datetime"; | 21 local datetime = require "util.datetime"; |
21 local hosts = prosody.hosts; | 22 local hosts = prosody.hosts; |
368 if session.presence then | 369 if session.presence then |
369 local pres = st.presence{ type = "unavailable" }; | 370 local pres = st.presence{ type = "unavailable" }; |
370 if err then | 371 if err then |
371 pres:tag("status"):text("Disconnected: "..err):up(); | 372 pres:tag("status"):text("Disconnected: "..err):up(); |
372 end | 373 end |
373 session:dispatch_stanza(pres); | 374 core_process_stanza(session, pres); |
374 elseif session.directed then | 375 elseif session.directed then |
375 local pres = st.presence{ type = "unavailable", from = session.full_jid }; | 376 local pres = st.presence{ type = "unavailable", from = session.full_jid }; |
376 if err then | 377 if err then |
377 pres:tag("status"):text("Disconnected: "..err):up(); | 378 pres:tag("status"):text("Disconnected: "..err):up(); |
378 end | 379 end |