From: Claire Date: Wed, 21 Jun 2023 09:21:50 +0000 (+0200) Subject: Use CLOCK_MONOTONIC instead of Time.now X-Git-Url: https://git.xn--scling-oua.cat.family/?a=commitdiff_plain;h=23320dcb7a653aa53794d89fc46b70bac2b620f2;p=mastodon.git Use CLOCK_MONOTONIC instead of Time.now Signed-off-by: Claire --- diff --git a/app/lib/request.rb b/app/lib/request.rb index 9d6c0dbfd..aaa8ff291 100644 --- a/app/lib/request.rb +++ b/app/lib/request.rb @@ -24,15 +24,15 @@ class HTTP::Timeout::PerOperation # Read data from the socket def readpartial(size, buffer = nil) - @deadline ||= Time.now + @read_timeout + @deadline ||= Process.clock_gettime(Process::CLOCK_MONOTONIC) + @read_timeout timeout = false loop do - result = @socket.read_nonblock(size, buffer, :exception => false) + result = @socket.read_nonblock(size, buffer, exception: false) return :eof if result.nil? - remaining_time = @deadline - Time.now + remaining_time = @deadline - Process.clock_gettime(Process::CLOCK_MONOTONIC) raise HTTP::TimeoutError, "Read timed out after #{@read_timeout} seconds" if timeout || remaining_time <= 0 return result if result != :wait_readable