Changeset

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 (2015-05-11)
parents 1731:b912cb8e0b3c
children 1733:9abd3dce619a
files mod_smacks/mod_smacks.lua
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
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");