mod_smacks: Handle unacked messages in s2s queues
authorKim Alvefur <zash@zash.se>
Mon, 11 May 2015 14:33:37 +0200
changeset 1736 2f9ee9ed6267
parent 1735 b912cb8e0b3c
child 1737 9abd3dce619a
mod_smacks: Handle unacked messages in s2s queues
mod_smacks/mod_smacks.lua
--- a/mod_smacks/mod_smacks.lua	Mon May 11 14:32:37 2015 +0200
+++ b/mod_smacks/mod_smacks.lua	Mon May 11 14:33:37 2015 +0200
@@ -298,6 +298,18 @@
 	end
 end);
 
+local function handle_s2s_destroyed(event)
+	local session = event.session;
+	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);
+	end
+end
+
+module:hook("s2sout-destroyed", handle_s2s_destroyed);
+module:hook("s2sin-destroyed", handle_s2s_destroyed);
+
 function handle_resume(session, stanza, xmlns_sm)
 	if session.full_jid then
 		session.log("warn", "Tried to resume after resource binding");