Software /
code /
prosody-modules
Comparison
mod_smacks/mod_smacks.lua @ 1881:3683eb95bc1a
mod_smacks: Add experimental resending of unacked messages in s2s queues (disabled by default)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 29 Sep 2015 21:54:40 +0200 |
parent | 1733:9abd3dce619a |
child | 2087:e48dbb640408 |
comparison
equal
deleted
inserted
replaced
1880:a7c1f1b6ef05 | 1881:3683eb95bc1a |
---|---|
29 local sm2_attr = { xmlns = xmlns_sm2 }; | 29 local sm2_attr = { xmlns = xmlns_sm2 }; |
30 local sm3_attr = { xmlns = xmlns_sm3 }; | 30 local sm3_attr = { xmlns = xmlns_sm3 }; |
31 | 31 |
32 local resume_timeout = module:get_option_number("smacks_hibernation_time", 300); | 32 local resume_timeout = module:get_option_number("smacks_hibernation_time", 300); |
33 local s2s_smacks = module:get_option_boolean("smacks_enabled_s2s", false); | 33 local s2s_smacks = module:get_option_boolean("smacks_enabled_s2s", false); |
34 local s2s_resend = module:get_option_boolean("smacks_s2s_resend", false); | |
34 local max_unacked_stanzas = module:get_option_number("smacks_max_unacked_stanzas", 0); | 35 local max_unacked_stanzas = module:get_option_number("smacks_max_unacked_stanzas", 0); |
35 local core_process_stanza = prosody.core_process_stanza; | 36 local core_process_stanza = prosody.core_process_stanza; |
36 local sessionmanager = require"core.sessionmanager"; | 37 local sessionmanager = require"core.sessionmanager"; |
37 | 38 |
38 local c2s_sessions = module:shared("/*/c2s/sessions"); | 39 local c2s_sessions = module:shared("/*/c2s/sessions"); |
301 local function handle_s2s_destroyed(event) | 302 local function handle_s2s_destroyed(event) |
302 local session = event.session; | 303 local session = event.session; |
303 local queue = session.outgoing_stanza_queue; | 304 local queue = session.outgoing_stanza_queue; |
304 if queue and #queue > 0 then | 305 if queue and #queue > 0 then |
305 session.log("warn", "Destroying session with %d unacked stanzas", #queue); | 306 session.log("warn", "Destroying session with %d unacked stanzas", #queue); |
306 handle_unacked_stanzas(session); | 307 if s2s_resend then |
308 for i = 1, #queue do | |
309 module:send(queue[i]); | |
310 end | |
311 session.outgoing_stanza_queue = nil; | |
312 else | |
313 handle_unacked_stanzas(session); | |
314 end | |
307 end | 315 end |
308 end | 316 end |
309 | 317 |
310 module:hook("s2sout-destroyed", handle_s2s_destroyed); | 318 module:hook("s2sout-destroyed", handle_s2s_destroyed); |
311 module:hook("s2sin-destroyed", handle_s2s_destroyed); | 319 module:hook("s2sin-destroyed", handle_s2s_destroyed); |