summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2013-06-24 07:14:56 +0100
committerSteve Kemp <steve@steve.org.uk>2013-06-24 07:14:56 +0100
commita07d07b110370a1b579d370429452dc63e033ff4 (patch)
treeb60be5303f556bfed6a977ee0f629062cc6af120
parent6dfa287626bbf700bb37debf1003181e57c55265 (diff)
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.
-rw-r--r--lib/custodian/util/dns.rb18
1 files 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 )