diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | lib/net/http.rb | 4 | ||||
-rw-r--r-- | lib/resolv.rb | 6 |
3 files changed, 10 insertions, 5 deletions
@@ -1,3 +1,8 @@ +Fri May 29 10:30:34 2015 Eric Wong <e@80x24.org> + + * lib/net/resolv.rb (request): use monotonic clock + * lib/net/http.rb (begin_transport, end_transport): ditto + Fri May 29 04:37:38 2015 Koichi Sasada <ko1@atdot.net> * ext/objspace/objspace.c: add two methods to debug internals. 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 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 |