From 19fd7ac18460e3e5206496cf5f6bf629aff3e2a9 Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Wed, 15 May 2013 16:20:41 +0100 Subject: Honour the global timeout period. The global configuration file, /etc/custodian/custodian.cfg, has a timeout=XX setting in it. Until now we've ignored it and used a fixed timeout of 20/30 seconds. Now we fully honour the specified value. --- lib/custodian/protocoltest/dns.rb | 9 ++++++++- lib/custodian/protocoltest/http.rb | 12 ++++++++++-- lib/custodian/protocoltest/openproxy.rb | 12 ++++++++++-- lib/custodian/protocoltest/ssh.rb | 1 + lib/custodian/protocoltest/tcp.rb | 10 +++++++++- 5 files changed, 38 insertions(+), 6 deletions(-) (limited to 'lib/custodian') diff --git a/lib/custodian/protocoltest/dns.rb b/lib/custodian/protocoltest/dns.rb index 4053747..daa0c4d 100644 --- a/lib/custodian/protocoltest/dns.rb +++ b/lib/custodian/protocoltest/dns.rb @@ -1,3 +1,4 @@ +require 'custodian/settings' require 'resolv' # @@ -93,10 +94,16 @@ module Custodian # Reset the result in case we've already run @error = nil + # + # Get the timeout period. + # + settings = Custodian::Settings.instance() + period = settings.timeout() + # # Do the lookup # - results = resolve_via( @host, @resolve_type, @resolve_name, 30 ) + results = resolve_via( @host, @resolve_type, @resolve_name, period ) return false if ( results.nil? ) # diff --git a/lib/custodian/protocoltest/http.rb b/lib/custodian/protocoltest/http.rb index 0450753..c52e36c 100644 --- a/lib/custodian/protocoltest/http.rb +++ b/lib/custodian/protocoltest/http.rb @@ -1,3 +1,5 @@ + +require 'custodian/settings' require 'uri' @@ -183,8 +185,14 @@ module Custodian return false end + # + # Get the timeout period for this test. + # + settings = Custodian::Settings.instance() + period = settings.timeout() + begin - timeout( 20 ) do + timeout( period ) do begin c = Curl::Easy.new(@url) @@ -198,7 +206,7 @@ module Custodian c.ssl_verify_host = false c.ssl_verify_peer = false - c.timeout = 20 + c.timeout = period c.perform @status = c.response_code @content = c.body_str diff --git a/lib/custodian/protocoltest/openproxy.rb b/lib/custodian/protocoltest/openproxy.rb index cb4371d..5313343 100644 --- a/lib/custodian/protocoltest/openproxy.rb +++ b/lib/custodian/protocoltest/openproxy.rb @@ -1,3 +1,5 @@ + +require 'custodian/settings' require 'uri' @@ -75,8 +77,14 @@ module Custodian return false end + # + # Get the timeout period for this test. + # + settings = Custodian::Settings.instance() + period = settings.timeout() + begin - timeout( 20 ) do + timeout( period ) do begin c = Curl::Easy.new() c.follow_location = true @@ -86,7 +94,7 @@ module Custodian c.proxy_tunnel = true c.url = "http://google.com/" c.ssl_verify_peer = false - c.timeout = 20 + c.timeout = period c.perform @status = c.response_code @content = c.body_str diff --git a/lib/custodian/protocoltest/ssh.rb b/lib/custodian/protocoltest/ssh.rb index a01404f..5e5a720 100644 --- a/lib/custodian/protocoltest/ssh.rb +++ b/lib/custodian/protocoltest/ssh.rb @@ -1,5 +1,6 @@ require 'custodian/protocoltest/tcp' + # # The SSH-protocol test. # diff --git a/lib/custodian/protocoltest/tcp.rb b/lib/custodian/protocoltest/tcp.rb index a28ed33..30083cd 100644 --- a/lib/custodian/protocoltest/tcp.rb +++ b/lib/custodian/protocoltest/tcp.rb @@ -1,4 +1,5 @@ +require 'custodian/settings' require 'custodian/testfactory' require 'socket' require 'timeout' @@ -140,8 +141,15 @@ module Custodian # # def run_test_internal( host, port, banner = nil, do_read = true ) + + # + # Get the timeout period for this test. + # + settings = Custodian::Settings.instance() + period = settings.timeout() + begin - timeout(30) do + timeout(period) do begin socket = TCPSocket.new( host, port ) -- cgit v1.2.1