Changeset

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
parents 1530:fb7cd669f41b
children 1532:71d85bc0dea8
files mod_smacks/mod_smacks.lua
diffstat 1 files changed, 13 insertions(+), 11 deletions(-) [+]
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)