--- Prosody IM v0.4
+-- Prosody IM
-- Copyright (C) 2008-2009 Matthew Wild
-- Copyright (C) 2008-2009 Waqas Hussain
--
end
open_sessions = open_sessions + 1;
local w, log = conn.write, logger_init("s2sin"..tostring(conn):match("[a-f0-9]+$"));
+ session.log = log;
session.sends2s = function (t) log("debug", "sending: %s", tostring(t)); w(tostring(t)); end
incoming_s2s[session] = true;
return session;
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
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
conn:settimeout(0);
local success, err = conn:connect(connect_host, connect_port);
if not success and err ~= "timeout" then
- log("warn", "s2s connect() failed: %s", err);
- return false;
+ log("warn", "s2s connect() to %s (%s:%d) failed: %s", host_session.to_host, connect_host, connect_port, err);
+ return false, err;
end
local cl = connlisteners_get("xmppserver");