summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2012-11-15 13:45:25 +0000
committerSteve Kemp <steve@steve.org.uk>2012-11-15 13:45:25 +0000
commit89e524a53142e2f9628745ea651563e5ef2211ba (patch)
tree765917bee49d79953b8e89fa67ad8ef448f59140 /lib
parent3ba848f256973ae6ab7a987f536587cd673228ac (diff)
Timeout on DNS failures.
Diffstat (limited to 'lib')
-rw-r--r--lib/custodian/multiping.rb15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/custodian/multiping.rb b/lib/custodian/multiping.rb
index 64c3573..a39e81b 100644
--- a/lib/custodian/multiping.rb
+++ b/lib/custodian/multiping.rb
@@ -1,7 +1,7 @@
require 'getoptlong'
require 'socket'
-
+require 'timeout'
class MultiPing
@@ -24,10 +24,17 @@ class MultiPing
res = nil
begin
- Socket.getaddrinfo(hostname, 'echo').each do |a|
- res = a[3]
+ timeout( 4 ) do
+
+ begin
+ Socket.getaddrinfo(hostname, 'echo').each do |a|
+ res = a[3]
+ end
+ rescue SocketError
+ end
end
- rescue SocketError
+ rescue Timeout::Error => e
+ resolved = nil
end
res