changeset 1524:604a8cee9d58

Merge
author Kim Alvefur <zash@zash.se>
date Mon, 13 Oct 2014 14:31:16 +0200
parents d4a4ed31567e (diff) 54f6158a4915 (current diff)
children 37cef218ba20
files
diffstat 1 files changed, 4 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mod_smacks/mod_smacks.lua	Sun Oct 12 17:09:07 2014 +0200
+++ b/mod_smacks/mod_smacks.lua	Mon Oct 13 14:31:16 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 = {};