Mercurial > prosody-hg
comparison core/s2smanager.lua @ 3329:9adafeeadecb
s2smanager: Lower default DNS timeout to 15s (it's now a per-DNS-server timeout, rather than total timeout), use net.dns's new timeout system, and remove our custom timeout handlers
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Mon, 05 Jul 2010 12:17:09 +0100 |
| parents | 12fc7e005e8b |
| children | c7acddf80583 |
comparison
equal
deleted
inserted
replaced
| 3328:5ac4fbbfb74d | 3329:9adafeeadecb |
|---|---|
| 40 local sha256_hash = require "util.hashes".sha256; | 40 local sha256_hash = require "util.hashes".sha256; |
| 41 | 41 |
| 42 local adns, dns = require "net.adns", require "net.dns"; | 42 local adns, dns = require "net.adns", require "net.dns"; |
| 43 local config = require "core.configmanager"; | 43 local config = require "core.configmanager"; |
| 44 local connect_timeout = config.get("*", "core", "s2s_timeout") or 60; | 44 local connect_timeout = config.get("*", "core", "s2s_timeout") or 60; |
| 45 local dns_timeout = config.get("*", "core", "dns_timeout") or 60; | 45 local dns_timeout = config.get("*", "core", "dns_timeout") or 15; |
| 46 local max_dns_depth = config.get("*", "core", "dns_max_depth") or 3; | 46 local max_dns_depth = config.get("*", "core", "dns_max_depth") or 3; |
| 47 | |
| 48 dns.settimeout(dns_timeout); | |
| 47 | 49 |
| 48 incoming_s2s = {}; | 50 incoming_s2s = {}; |
| 49 _G.prosody.incoming_s2s = incoming_s2s; | 51 _G.prosody.incoming_s2s = incoming_s2s; |
| 50 local incoming_s2s = incoming_s2s; | 52 local incoming_s2s = incoming_s2s; |
| 51 | 53 |
| 247 destroy_session(host_session, err); | 249 destroy_session(host_session, err); |
| 248 end | 250 end |
| 249 end | 251 end |
| 250 end, "_xmpp-server._tcp."..connect_host..".", "SRV"); | 252 end, "_xmpp-server._tcp."..connect_host..".", "SRV"); |
| 251 | 253 |
| 252 -- Set handler for DNS timeout | |
| 253 add_task(dns_timeout, function () | |
| 254 if handle then | |
| 255 adns.cancel(handle, true); | |
| 256 end | |
| 257 end); | |
| 258 | |
| 259 return true; -- Attempt in progress | 254 return true; -- Attempt in progress |
| 260 elseif host_session.srv_hosts and #host_session.srv_hosts > host_session.srv_choice then -- Not our first attempt, and we also have SRV | 255 elseif host_session.srv_hosts and #host_session.srv_hosts > host_session.srv_choice then -- Not our first attempt, and we also have SRV |
| 261 host_session.srv_choice = host_session.srv_choice + 1; | 256 host_session.srv_choice = host_session.srv_choice + 1; |
| 262 local srv_choice = host_session.srv_hosts[host_session.srv_choice]; | 257 local srv_choice = host_session.srv_hosts[host_session.srv_choice]; |
| 263 connect_host, connect_port = srv_choice.target or to_host, srv_choice.port or connect_port; | 258 connect_host, connect_port = srv_choice.target or to_host, srv_choice.port or connect_port; |
| 306 destroy_session(host_session, "DNS resolution failed"); -- End of the line, we can't | 301 destroy_session(host_session, "DNS resolution failed"); -- End of the line, we can't |
| 307 end | 302 end |
| 308 end | 303 end |
| 309 end, connect_host, "A", "IN"); | 304 end, connect_host, "A", "IN"); |
| 310 | 305 |
| 311 -- Set handler for DNS timeout | |
| 312 add_task(dns_timeout, function () | |
| 313 if handle then | |
| 314 adns.cancel(handle, true); | |
| 315 end | |
| 316 end); | |
| 317 | |
| 318 return true; | 306 return true; |
| 319 end | 307 end |
| 320 | 308 |
| 321 function make_connect(host_session, connect_host, connect_port) | 309 function make_connect(host_session, connect_host, connect_port) |
| 322 (host_session.log or log)("info", "Beginning new connection attempt to %s (%s:%d)", host_session.to_host, connect_host, connect_port); | 310 (host_session.log or log)("info", "Beginning new connection attempt to %s (%s:%d)", host_session.to_host, connect_host, connect_port); |
