aboutsummaryrefslogtreecommitdiffstats
path: root/core/s2smanager.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2009-04-20 22:14:31 +0100
committerMatthew Wild <mwild1@gmail.com>2009-04-20 22:14:31 +0100
commit7b9dbf5747ba99cad4730bc6b70639fadc1cdc0a (patch)
tree70691cbd2ba7a101974502d67f52a5760de14bd4 /core/s2smanager.lua
parent27ef148e7092f79ea656f2831f908346cd5d5433 (diff)
downloadprosody-7b9dbf5747ba99cad4730bc6b70639fadc1cdc0a.tar.gz
prosody-7b9dbf5747ba99cad4730bc6b70639fadc1cdc0a.zip
core.s2smanager: Buffer data sent before connection
Diffstat (limited to 'core/s2smanager.lua')
-rw-r--r--core/s2smanager.lua31
1 files changed, 31 insertions, 0 deletions
diff --git a/core/s2smanager.lua b/core/s2smanager.lua
index 5a557daf..a16f8b02 100644
--- a/core/s2smanager.lua
+++ b/core/s2smanager.lua
@@ -141,6 +141,23 @@ function new_outgoing(from_host, to_host)
attempt_connection(host_session);
+ if not host_session.sends2s then
+ -- A sends2s which buffers data (until the stream is opened)
+ -- note that data in this buffer will be sent before the stream is authed
+ -- and will not be ack'd in any way, successful or otherwise
+ local buffer;
+ function host_session.sends2s(data)
+ if not buffer then
+ buffer = {};
+ host_session.send_buffer = buffer;
+ end
+ log("debug", "Buffering data on unconnected s2sout to %s", to_host);
+ buffer[#buffer+1] = data;
+ log("debug", "Buffered item %d: %s", #buffer, tostring(data));
+ end
+
+ end
+
return host_session;
end
@@ -263,6 +280,20 @@ function streamopened(session, attr)
if not attr.id then error("stream response did not give us a streamid!!!"); end
session.streamid = attr.id;
+ -- Send unauthed buffer
+ -- (stanzas which are fine to send before dialback)
+ -- Note that this is *not* the stanza queue (which
+ -- we can only send if auth succeeds) :)
+ local send_buffer = session.send_buffer;
+ if send_buffer and #send_buffer > 0 then
+ log("debug", "Sending s2s send_buffer now...");
+ for i, data in ipairs(send_buffer) do
+ session.sends2s(tostring(data));
+ send_buffer[i] = nil;
+ end
+ end
+ session.send_buffer = nil;
+
if not session.dialback_verifying then
initiate_dialback(session);
else