aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2009-09-19 17:42:16 +0100
committerMatthew Wild <mwild1@gmail.com>2009-09-19 17:42:16 +0100
commit818bece2e6d8afbb42001c4ca5f23ff4a808123d (patch)
tree241493a7141397fcb0a169a39660df4584271578 /core
parent080222fe19392b99d0822c6ad82153175c0a97df (diff)
parent44ea588e9845a66134fe3bd4fab9e9c8ba4d66eb (diff)
downloadprosody-818bece2e6d8afbb42001c4ca5f23ff4a808123d.tar.gz
prosody-818bece2e6d8afbb42001c4ca5f23ff4a808123d.zip
Merge with 0.5
Diffstat (limited to 'core')
-rw-r--r--core/s2smanager.lua30
1 files changed, 29 insertions, 1 deletions
diff --git a/core/s2smanager.lua b/core/s2smanager.lua
index ab2e4a5c..2affe486 100644
--- a/core/s2smanager.lua
+++ b/core/s2smanager.lua
@@ -174,7 +174,7 @@ function attempt_connection(host_session, err)
if not err then -- This is our first attempt
log("debug", "First attempt to connect to %s, starting with SRV lookup...", to_host);
host_session.connecting = true;
- local answer, handle;
+ local handle;
handle = adns.lookup(function (answer)
handle = nil;
host_session.connecting = nil;
@@ -236,6 +236,34 @@ function attempt_connection(host_session, err)
end
function try_connect(host_session, connect_host, connect_port)
+ host_session.connecting = true;
+ local handle;
+ handle = adns.lookup(function (reply)
+ handle = nil;
+ host_session.connecting = nil;
+ if reply and reply[1] and reply[1].a then
+ log("debug", "DNS reply for %s gives us %s", connect_host, reply[1].a);
+ return make_connect(host_session, reply[1].a, connect_port);
+ else
+ log("debug", "DNS lookup failed to get a response for %s", connect_host);
+ if not attempt_connection(host_session, "name resolution failed") then -- Retry if we can
+ log("debug", "No other records to try for %s - destroying", host_session.to_host);
+ destroy_session(host_session); -- End of the line, we can't
+ end
+ end
+ end, connect_host, "A", "IN");
+
+ -- Set handler for DNS timeout
+ add_task(dns_timeout, function ()
+ if handle then
+ adns.cancel(handle, true);
+ end
+ end);
+
+ return true;
+end
+
+function make_connect(host_session, connect_host, connect_port)
host_session.log("info", "Beginning new connection attempt to %s (%s:%d)", host_session.to_host, connect_host, connect_port);
-- Ok, we're going to try to connect