Skip to content

Commit bb4d5e1

Browse files
committed
Merge pull request #322 from httprb/tarcieri/fix-timeouterror-bug
Revert to IO.select for PerOperation timeouts (fixes #298)
2 parents da67458 + 4ab3729 commit bb4d5e1

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

lib/http/timeout/per_operation.rb

+3-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def connect(socket_class, host, port, nodelay = false)
2929
def connect_ssl
3030
rescue_readable do
3131
rescue_writable do
32-
socket.connect_nonblock
32+
@socket.connect_nonblock
3333
end
3434
end
3535
end
@@ -66,7 +66,7 @@ def readpartial(size)
6666
return result
6767
end
6868

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

81-
unless @socket.to_io.wait_writable(write_timeout)
81+
unless IO.select(nil, [@socket], nil, write_timeout)
8282
fail TimeoutError, "Write timed out after #{write_timeout} seconds"
8383
end
8484
end
8585
end
8686
end
87-
# rubocop:enable Metrics/BlockNesting
8887
end
8988
end
9089
end

0 commit comments

Comments
 (0)