diff mod_smacks/mod_smacks.lua @ 2088:7a29d8e3275b

mod_smacks: Go back to sending ack requests from a timer a moment after a stanza was sent
author Kim Alvefur <zash@zash.se>
date Wed, 16 Mar 2016 13:26:21 +0100
parents e48dbb640408
children 964b3d649a36
line wrap: on
line diff
--- a/mod_smacks/mod_smacks.lua	Wed Mar 16 13:14:01 2016 +0100
+++ b/mod_smacks/mod_smacks.lua	Wed Mar 16 13:26:21 2016 +0100
@@ -88,8 +88,14 @@
 			return nil;
 		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 }));
+			session.log("debug", "Queuing <r> (in a moment)");
+			module:add_timer(1e-06, function ()
+				if not session.awaiting_ack then
+					session.awaiting_ack = true;
+					session.log("debug", "Sending <r> (after send)");
+					(session.sends2s or session.send)(st.stanza("r", { xmlns = session.smacks }))
+				end
+			end);
 		end
 	end
 	return stanza;