diff options
author | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-05-29 01:40:26 +0000 |
---|---|---|
committer | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-05-29 01:40:26 +0000 |
commit | 16aeffefa2670d7d3317488a46f2cc4e1a93fac0 (patch) | |
tree | 030f2fa67c7115f901dcd003a80efb407c8425b0 /lib/resolv.rb | |
parent | c1b35ab11e38382fc80b7c45d368710f99abd094 (diff) |
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.rb | 6 |
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 |