changeset 1522:d4a4ed31567e

mod_smacks: Trick session.send() into not returning nil or mod_message will act as if messages were not delivered
author Kim Alvefur <zash@zash.se>
date Mon, 13 Oct 2014 14:19:49 +0200 (2014-10-13)
parents 71af9c272d72
children 604a8cee9d58
files mod_smacks/mod_smacks.lua
diffstat 1 files changed, 4 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mod_smacks/mod_smacks.lua	Sun Oct 12 16:05:48 2014 +0200
+++ b/mod_smacks/mod_smacks.lua	Mon Oct 13 14:19:49 2014 +0200
@@ -72,7 +72,6 @@
 	local is_stanza = stanza.attr and not stanza.attr.xmlns;
 	if is_stanza and not stanza._cached then -- Stanza in default stream namespace
 		local queue = session.outgoing_stanza_queue;
-		module:log("debug", "st.clone( %s ) -- %s a stanza", tostring(stanza), is_stanza and "is" or "is not");
 		local cached_stanza = st.clone(stanza);
 		cached_stanza._cached = true;
 
@@ -82,6 +81,10 @@
 
 		queue[#queue+1] = cached_stanza;
 		session.log("debug", "#queue = %d", #queue);
+		if session.hibernating then
+			session.log("debug", "hibernating, stanza queued");
+			return ""; -- Hack to make session.send() not return nil
+		end
 		if #queue > max_unacked_stanzas then
 			module:add_timer(0, function ()
 				if not session.awaiting_ack then
@@ -91,12 +94,6 @@
 			end);
 		end
 	end
-	if session.hibernating then
-		session.log("debug", "hibernating, stanza queued")
-		-- The session is hibernating, no point in sending the stanza
-		-- over a dead connection.  It will be delivered upon resumption.
-		return nil; -- or empty string?
-	end
 	return stanza;
 end
 
@@ -109,7 +106,6 @@
 end
 
 local function wrap_session(session, resume)
-	-- Overwrite process_stanza() and send()
 	local queue;
 	if not resume then
 		queue = {};