Skip to content

Commit

Permalink
Merge pull request #362 from TiagoCardoso1983/issue_359
Browse files Browse the repository at this point in the history
connect_ssl uses connect_timeout (Closes #359)
  • Loading branch information
tarcieri authored Aug 9, 2016
2 parents 0f45479 + 09721ee commit f3a9798
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions lib/http/timeout/null.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,19 @@ def write(data)
private

# Retry reading
def rescue_readable
def rescue_readable(timeout = read_timeout)
yield
rescue IO::WaitReadable
retry if @socket.to_io.wait_readable(read_timeout)
raise TimeoutError, "Read timed out after #{read_timeout} seconds"
retry if @socket.to_io.wait_readable(timeout)
raise TimeoutError, "Read timed out after #{timeout} seconds"
end

# Retry writing
def rescue_writable
def rescue_writable(timeout = write_timeout)
yield
rescue IO::WaitWritable
retry if @socket.to_io.wait_writable(write_timeout)
raise TimeoutError, "Write timed out after #{write_timeout} seconds"
retry if @socket.to_io.wait_writable(timeout)
raise TimeoutError, "Write timed out after #{timeout} seconds"
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/http/timeout/per_operation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def connect(socket_class, host, port, nodelay = false)
end

def connect_ssl
rescue_readable do
rescue_writable do
rescue_readable(@connect_timeout) do
rescue_writable(@connect_timeout) do
@socket.connect_nonblock
end
end
Expand Down

0 comments on commit f3a9798

Please sign in to comment.