Changeset

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 1538:57bb2497fadc
children 1540:0c26b1638f8c
files mod_smacks/mod_smacks.lua
diffstat 1 files changed, 3 insertions(+), 7 deletions(-) [+]
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;