From 23320dcb7a653aa53794d89fc46b70bac2b620f2 Mon Sep 17 00:00:00 2001 From: Claire Date: Wed, 21 Jun 2023 11:21:50 +0200 Subject: [PATCH] Use CLOCK_MONOTONIC instead of Time.now Signed-off-by: Claire --- app/lib/request.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 -- 2.47.3