Diff

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
parent 3312:12fc7e005e8b
child 3383:c7acddf80583
line wrap: on
line diff
--- a/core/s2smanager.lua	Mon Jul 05 12:13:55 2010 +0100
+++ b/core/s2smanager.lua	Mon Jul 05 12:17:09 2010 +0100
@@ -42,9 +42,11 @@
 local adns, dns = require "net.adns", require "net.dns";
 local config = require "core.configmanager";
 local connect_timeout = config.get("*", "core", "s2s_timeout") or 60;
-local dns_timeout = config.get("*", "core", "dns_timeout") or 60;
+local dns_timeout = config.get("*", "core", "dns_timeout") or 15;
 local max_dns_depth = config.get("*", "core", "dns_max_depth") or 3;
 
+dns.settimeout(dns_timeout);
+
 incoming_s2s = {};
 _G.prosody.incoming_s2s = incoming_s2s;
 local incoming_s2s = incoming_s2s;
@@ -249,13 +251,6 @@
 			end
 		end, "_xmpp-server._tcp."..connect_host..".", "SRV");
 		
-		-- Set handler for DNS timeout
-		add_task(dns_timeout, function ()
-			if handle then
-				adns.cancel(handle, true);
-			end
-		end);
-		
 		return true; -- Attempt in progress
 	elseif host_session.srv_hosts and #host_session.srv_hosts > host_session.srv_choice then -- Not our first attempt, and we also have SRV
 		host_session.srv_choice = host_session.srv_choice + 1;
@@ -308,13 +303,6 @@
 		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