Diff

mod_smacks/mod_smacks.lua @ 1531:7d86fc477993

mod_smacks: Delay initiation of outgoing smacks on s2s until after queued stanzas are sent
author Kim Alvefur <zash@zash.se>
date Mon, 20 Oct 2014 13:15:55 +0200
parent 1530:fb7cd669f41b
child 1539:05fa54404012
line wrap: on
line diff
--- a/mod_smacks/mod_smacks.lua	Mon Oct 20 13:15:14 2014 +0200
+++ b/mod_smacks/mod_smacks.lua	Mon Oct 20 13:15:55 2014 +0200
@@ -156,18 +156,20 @@
 
 module:hook_stanza("http://etherx.jabber.org/streams", "features",
 		function (session, stanza)
-			if can_do_smacks(session) then
-				if stanza:get_child("sm", xmlns_sm3) then
-					session.sends2s(st.stanza("enable", sm3_attr));
-					session.smacks = xmlns_sm3;
-				elseif stanza:get_child("sm", xmlns_sm2) then
-					session.sends2s(st.stanza("enable", sm2_attr));
-					session.smacks = xmlns_sm2;
-				else
-					return;
+			module:add_timer(0, function ()
+				if can_do_smacks(session) then
+					if stanza:get_child("sm", xmlns_sm3) then
+						session.sends2s(st.stanza("enable", sm3_attr));
+						session.smacks = xmlns_sm3;
+					elseif stanza:get_child("sm", xmlns_sm2) then
+						session.sends2s(st.stanza("enable", sm2_attr));
+						session.smacks = xmlns_sm2;
+					else
+						return;
+					end
+					wrap_session_out(session, false);
 				end
-				wrap_session_out(session, false);
-			end
+			end);
 		end);
 
 function handle_enabled(session, stanza, xmlns_sm)