Diff

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
line wrap: on
line diff
--- a/mod_smacks/mod_smacks.lua	Tue Sep 29 14:56:46 2015 +0200
+++ b/mod_smacks/mod_smacks.lua	Tue Sep 29 21:54:40 2015 +0200
@@ -31,6 +31,7 @@
 
 local resume_timeout = module:get_option_number("smacks_hibernation_time", 300);
 local s2s_smacks = module:get_option_boolean("smacks_enabled_s2s", false);
+local s2s_resend = module:get_option_boolean("smacks_s2s_resend", false);
 local max_unacked_stanzas = module:get_option_number("smacks_max_unacked_stanzas", 0);
 local core_process_stanza = prosody.core_process_stanza;
 local sessionmanager = require"core.sessionmanager";
@@ -303,7 +304,14 @@
 	local queue = session.outgoing_stanza_queue;
 	if queue and #queue > 0 then
 		session.log("warn", "Destroying session with %d unacked stanzas", #queue);
-		handle_unacked_stanzas(session);
+		if s2s_resend then
+			for i = 1, #queue do
+				module:send(queue[i]);
+			end
+			session.outgoing_stanza_queue = nil;
+		else
+			handle_unacked_stanzas(session);
+		end
 	end
 end