mod_s2s: Don't cache session.sends2s (or do it later), prevents sending data after session was closed
authorKim Alvefur <zash@zash.se>
Wed, 13 May 2015 21:55:08 +0200
changeset 6686 873ad1023eb0
parent 6685 63f5870f9afe
child 6687 53635a91c95c
mod_s2s: Don't cache session.sends2s (or do it later), prevents sending data after session was closed
plugins/mod_s2s/mod_s2s.lua
--- a/plugins/mod_s2s/mod_s2s.lua	Wed May 13 21:47:39 2015 +0200
+++ b/plugins/mod_s2s/mod_s2s.lua	Wed May 13 21:55:08 2015 +0200
@@ -147,7 +147,7 @@
 
 -- Stream is authorised, and ready for normal stanzas
 function mark_connected(session)
-	local sendq, send = session.sendq, session.sends2s;
+	local sendq = session.sendq;
 	
 	local from, to = session.from_host, session.to_host;
 	
@@ -170,6 +170,7 @@
 	if session.direction == "outgoing" then
 		if sendq then
 			session.log("debug", "sending %d queued stanzas across new outgoing connection to %s", #sendq, session.to_host);
+			local send = session.sends2s;
 			for i, data in ipairs(sendq) do
 				send(data[1]);
 				sendq[i] = nil;
@@ -269,8 +270,6 @@
 local xmlns_xmpp_streams = "urn:ietf:params:xml:ns:xmpp-streams";
 
 function stream_callbacks.streamopened(session, attr)
-	local send = session.sends2s;
-	
 	session.version = tonumber(attr.version) or 0;
 	
 	-- TODO: Rename session.secure to session.encrypted
@@ -360,7 +359,7 @@
 			end
 			
 			log("debug", "Sending stream features: %s", tostring(features));
-			send(features);
+			session.sends2s(features);
 		end
 		session.notopen = nil;
 	elseif session.direction == "outgoing" then