aboutsummaryrefslogtreecommitdiffstats
path: root/core/s2smanager.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2009-07-08 03:14:12 +0100
committerMatthew Wild <mwild1@gmail.com>2009-07-08 03:14:12 +0100
commit25c8f0ffa440c9fe664b187cc19b322e7b37ae39 (patch)
tree0ac2b5d91013885ae84acf571b14315a9e2548d3 /core/s2smanager.lua
parent1b554164a066afbc2a1652a38e8757c816a6bb79 (diff)
downloadprosody-25c8f0ffa440c9fe664b187cc19b322e7b37ae39.tar.gz
prosody-25c8f0ffa440c9fe664b187cc19b322e7b37ae39.zip
s2smanager: Fix to correctly bounce stanzas if first connection attempt fails instantly
Diffstat (limited to 'core/s2smanager.lua')
-rw-r--r--core/s2smanager.lua11
1 files changed, 9 insertions, 2 deletions
diff --git a/core/s2smanager.lua b/core/s2smanager.lua
index 75bb5d36..e095a620 100644
--- a/core/s2smanager.lua
+++ b/core/s2smanager.lua
@@ -142,6 +142,7 @@ function new_outgoing(from_host, to_host)
host_session.log = log;
end
+ -- This is the first call, can't fail (the first step is DNS lookup)
attempt_connection(host_session);
if not host_session.sends2s then
@@ -195,7 +196,13 @@ function attempt_connection(host_session, err)
log("debug", to_host.." has no SRV records, falling back to A");
end
-- Try with SRV, or just the plain hostname if no SRV
- return try_connect(host_session, connect_host, connect_port);
+ local ok, err = try_connect(host_session, connect_host, connect_port);
+ if not ok then
+ if not attempt_connection(host_session, err) then
+ -- No more attempts will be made
+ destroy_session(host_session);
+ end
+ end
end, "_xmpp-server._tcp."..connect_host..".", "SRV");
-- Set handler for DNS timeout
@@ -239,7 +246,7 @@ function try_connect(host_session, connect_host, connect_port)
local success, err = conn:connect(connect_host, connect_port);
if not success and err ~= "timeout" then
log("warn", "s2s connect() to %s (%s:%d) failed: %s", host_session.to_host, connect_host, connect_port, err);
- return false;
+ return false, err;
end
local cl = connlisteners_get("xmppserver");