From 08e738f8c6606424dbc20152b18523fe6fcb6818 Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Mon, 24 Jun 2013 07:14:56 +0100 Subject: Use the global timeout-period for DNS lookups. The rest of custodian will use the configuration file to read the timeout value (with a default of 30 seconds), but the DNS-lookups were hardwired to timeout after four seconds. This is now resolved; the DNS lookups will use the global timeout period too now. --- lib/custodian/util/dns.rb | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/custodian/util/dns.rb b/lib/custodian/util/dns.rb index a26cc96..e04361d 100644 --- a/lib/custodian/util/dns.rb +++ b/lib/custodian/util/dns.rb @@ -1,5 +1,6 @@ +require 'custodian/settings' require 'ipaddr' require 'socket' require 'timeout' @@ -21,8 +22,15 @@ module Custodian # def DNS.ip_to_hostname( ip ) resolved = nil + + # + # Get the timeout period. + # + settings = Custodian::Settings.instance() + period = settings.timeout() + begin - timeout( 4 ) do + timeout( period ) do begin Socket.getaddrinfo(ip, 'echo').each do |a| resolved = a[2] if ( a ) @@ -45,8 +53,14 @@ module Custodian resolved = nil + # + # Get the timeout period. + # + settings = Custodian::Settings.instance() + period = settings.timeout() + begin - timeout( 4 ) do + timeout( period ) do begin Socket.getaddrinfo(hostname, 'echo').each do |a| resolved = a[3] if ( a ) -- cgit v1.2.1