Skip to content

Commit

Permalink
Revert to IO.select for PerOperation timeouts (fixes #298)
Browse files Browse the repository at this point in the history
I have tried the repro case from #298 from this and this appears to
fix the problem.

Not sure why: the intended semantics appear to be equivalent. Possibly
a MRI bug that was fixed in 2.3?
  • Loading branch information
tarcieri committed Mar 21, 2016
1 parent da67458 commit 4ab3729
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/http/timeout/per_operation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def connect(socket_class, host, port, nodelay = false)
def connect_ssl
rescue_readable do
rescue_writable do
socket.connect_nonblock
@socket.connect_nonblock
end
end
end
Expand Down Expand Up @@ -66,7 +66,7 @@ def readpartial(size)
return result
end

unless @socket.to_io.wait_readable(read_timeout)
unless IO.select([@socket], nil, nil, read_timeout)
fail TimeoutError, "Read timed out after #{read_timeout} seconds"
end
end
Expand All @@ -78,13 +78,12 @@ def write(data)
result = @socket.write_nonblock(data, :exception => false)
return result unless result == :wait_writable

unless @socket.to_io.wait_writable(write_timeout)
unless IO.select(nil, [@socket], nil, write_timeout)
fail TimeoutError, "Write timed out after #{write_timeout} seconds"
end
end
end
end
# rubocop:enable Metrics/BlockNesting
end
end
end

0 comments on commit 4ab3729

Please sign in to comment.