Diff

mod_smacks/mod_smacks.lua @ 1732:2f9ee9ed6267

mod_smacks: Handle unacked messages in s2s queues
author Kim Alvefur <zash@zash.se>
date Mon, 11 May 2015 14:33:37 +0200
parent 1706:e4867211cddb
child 1733:9abd3dce619a
line wrap: on
line diff
--- 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");