Software /
code /
prosody
Comparison
core/s2smanager.lua @ 1492:aaeccebad0f3
s2smanager: Fix to correctly bounce stanzas if first connection attempt fails instantly
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 08 Jul 2009 03:14:12 +0100 |
parent | 1468:83b297a412a2 |
child | 1523:841d61be198f |
comparison
equal
deleted
inserted
replaced
1491:694a0a00e1a5 | 1492:aaeccebad0f3 |
---|---|
140 local conn_name = "s2sout"..tostring(host_session):match("[a-f0-9]*$"); | 140 local conn_name = "s2sout"..tostring(host_session):match("[a-f0-9]*$"); |
141 log = logger_init(conn_name); | 141 log = logger_init(conn_name); |
142 host_session.log = log; | 142 host_session.log = log; |
143 end | 143 end |
144 | 144 |
145 -- This is the first call, can't fail (the first step is DNS lookup) | |
145 attempt_connection(host_session); | 146 attempt_connection(host_session); |
146 | 147 |
147 if not host_session.sends2s then | 148 if not host_session.sends2s then |
148 -- A sends2s which buffers data (until the stream is opened) | 149 -- A sends2s which buffers data (until the stream is opened) |
149 -- note that data in this buffer will be sent before the stream is authed | 150 -- note that data in this buffer will be sent before the stream is authed |
193 end | 194 end |
194 else | 195 else |
195 log("debug", to_host.." has no SRV records, falling back to A"); | 196 log("debug", to_host.." has no SRV records, falling back to A"); |
196 end | 197 end |
197 -- Try with SRV, or just the plain hostname if no SRV | 198 -- Try with SRV, or just the plain hostname if no SRV |
198 return try_connect(host_session, connect_host, connect_port); | 199 local ok, err = try_connect(host_session, connect_host, connect_port); |
200 if not ok then | |
201 if not attempt_connection(host_session, err) then | |
202 -- No more attempts will be made | |
203 destroy_session(host_session); | |
204 end | |
205 end | |
199 end, "_xmpp-server._tcp."..connect_host..".", "SRV"); | 206 end, "_xmpp-server._tcp."..connect_host..".", "SRV"); |
200 | 207 |
201 -- Set handler for DNS timeout | 208 -- Set handler for DNS timeout |
202 add_task(dns_timeout, function () | 209 add_task(dns_timeout, function () |
203 if handle then | 210 if handle then |
237 | 244 |
238 conn:settimeout(0); | 245 conn:settimeout(0); |
239 local success, err = conn:connect(connect_host, connect_port); | 246 local success, err = conn:connect(connect_host, connect_port); |
240 if not success and err ~= "timeout" then | 247 if not success and err ~= "timeout" then |
241 log("warn", "s2s connect() to %s (%s:%d) failed: %s", host_session.to_host, connect_host, connect_port, err); | 248 log("warn", "s2s connect() to %s (%s:%d) failed: %s", host_session.to_host, connect_host, connect_port, err); |
242 return false; | 249 return false, err; |
243 end | 250 end |
244 | 251 |
245 local cl = connlisteners_get("xmppserver"); | 252 local cl = connlisteners_get("xmppserver"); |
246 conn = wrapclient(conn, connect_host, connect_port, cl, cl.default_mode or 1, hosts[from_host].ssl_ctx, false ); | 253 conn = wrapclient(conn, connect_host, connect_port, cl, cl.default_mode or 1, hosts[from_host].ssl_ctx, false ); |
247 host_session.conn = conn; | 254 host_session.conn = conn; |