aboutsummaryrefslogtreecommitdiffstats
path: root/lib/resolv.rb
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-29 01:40:26 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-29 01:40:26 +0000
commitb1de86187f88de6ebcc8bc0e8f64139ec422cb6c (patch)
tree030f2fa67c7115f901dcd003a80efb407c8425b0 /lib/resolv.rb
parent41b5a98b79ea24aec29a7e6902cfa895cfdafbe5 (diff)
downloadruby-b1de86187f88de6ebcc8bc0e8f64139ec422cb6c.tar.gz
lib/*: use monotonic clock for timeouts
The monotonic clock is preferred as it is guaranteed to be continuous and not subject to jumps due to adjustments. * lib/net/resolv.rb (request): use monotonic clock * lib/net/http.rb (begin_transport, end_transport): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50664 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/resolv.rb')
-rw-r--r--lib/resolv.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/resolv.rb b/lib/resolv.rb
index 9083bd0b53..ce36acf01f 100644
--- a/lib/resolv.rb
+++ b/lib/resolv.rb
@@ -667,7 +667,7 @@ class Resolv
end
def request(sender, tout)
- start = Time.now
+ start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
timelimit = start + tout
begin
sender.send
@@ -676,7 +676,7 @@ class Resolv
raise ResolvTimeout
end
while true
- before_select = Time.now
+ before_select = Process.clock_gettime(Process::CLOCK_MONOTONIC)
timeout = timelimit - before_select
if timeout <= 0
raise ResolvTimeout
@@ -687,7 +687,7 @@ class Resolv
select_result = IO.select(@socks, nil, nil, timeout)
end
if !select_result
- after_select = Time.now
+ after_select = Process.clock_gettime(Process::CLOCK_MONOTONIC)
next if after_select < timelimit
raise ResolvTimeout
end