diff mod_smacks/mod_smacks.lua @ 1539:05fa54404012

mod_smacks: Send ack requests by serializing and concatenating them to outgoing stanzas, using a timer might cause high CPU usage
author Kim Alvefur <zash@zash.se>
date Tue, 28 Oct 2014 22:26:41 +0100
parents 7d86fc477993
children dc0cf2ba0e1a
line wrap: on
line diff
--- a/mod_smacks/mod_smacks.lua	Tue Oct 28 15:24:50 2014 +0100
+++ b/mod_smacks/mod_smacks.lua	Tue Oct 28 22:26:41 2014 +0100
@@ -74,13 +74,9 @@
 			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
-					session.awaiting_ack = true;
-					(session.sends2s or session.send)(st.stanza("r", { xmlns = session.smacks }));
-				end
-			end);
+		if #queue > max_unacked_stanzas and not session.awaiting_ack then
+			session.awaiting_ack = true;
+			return tostring(stanza)..tostring(st.stanza("r", { xmlns = session.smacks }));
 		end
 	end
 	return stanza;