changeset 622:ce39df945de1

mod_smacks: Use pre-resource-unbind (0.9 feature) to fix reloadability and multiple host support
author Matthew Wild <mwild1@gmail.com>
date Mon, 05 Mar 2012 16:53:30 +0000
parents 7bdd02056e2b
children c1f3958695ea
files mod_smacks/mod_smacks.lua
diffstat 1 files changed, 4 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mod_smacks/mod_smacks.lua	Tue Feb 28 14:37:42 2012 +0100
+++ b/mod_smacks/mod_smacks.lua	Mon Mar 05 16:53:30 2012 +0000
@@ -198,8 +198,8 @@
 	end
 end
 
-local _destroy_session = sessionmanager.destroy_session;
-function sessionmanager.destroy_session(session, err)
+module:hook("pre-resource-unbind", function (event)
+	local session, err = event.session, event.error;
 	if session.smacks then
 		if not session.resumption_token then
 			local queue = session.outgoing_stanza_queue;
@@ -229,19 +229,16 @@
 					session.log("debug", "Destroying session for hibernating too long");
 					session_registry[session.resumption_token] = nil;
 					session.resumption_token = nil;
-					-- This recursion back into our destroy handler is to
-					-- make sure we still handle any queued stanzas
 					sessionmanager.destroy_session(session);
 				else
 					session.log("debug", "Session resumed before hibernation timeout, all is well")
 				end
 			end);
-			return; -- Postpone destruction for now
+			return true; -- Postpone destruction for now
 		end
 		
 	end
-	return _destroy_session(session, err);
-end
+end);
 
 module:hook_stanza(xmlns_sm, "resume", function (session, stanza)
 	local id = stanza.attr.previd;