aboutsummaryrefslogtreecommitdiffstats
path: root/lib/net
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/net
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/net')
-rw-r--r--lib/net/http.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/net/http.rb b/lib/net/http.rb
index 2fc541c2e8..4c1c3271ae 100644
--- a/lib/net/http.rb
+++ b/lib/net/http.rb
@@ -1460,7 +1460,7 @@ module Net #:nodoc:
def begin_transport(req)
if @socket.closed?
connect
- elsif @last_communicated && @last_communicated + @keep_alive_timeout < Time.now
+ elsif @last_communicated && @last_communicated + @keep_alive_timeout < Process.clock_gettime(Process::CLOCK_MONOTONIC)
D 'Conn close because of keep_alive_timeout'
@socket.close
connect
@@ -1484,7 +1484,7 @@ module Net #:nodoc:
@socket.close
elsif keep_alive?(req, res)
D 'Conn keep-alive'
- @last_communicated = Time.now
+ @last_communicated = Process.clock_gettime(Process::CLOCK_MONOTONIC)
else
D 'Conn close'
@socket.close