Skip to content

Revert "Replace Timeout.timeout with socket timeout" #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions lib/net/ftp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -356,19 +356,14 @@ def return_code=(s) # :nodoc:
# SOCKS_SERVER, then a SOCKSSocket is returned, else a Socket is
# returned.
def open_socket(host, port) # :nodoc:
if defined? SOCKSSocket and ENV["SOCKS_SERVER"]
@passive = true
Timeout.timeout(@open_timeout, OpenTimeout) do
return Timeout.timeout(@open_timeout, OpenTimeout) {
if defined? SOCKSSocket and ENV["SOCKS_SERVER"]
@passive = true
SOCKSSocket.open(host, port)
else
Socket.tcp(host, port)
end
else
begin
Socket.tcp host, port, nil, nil, connect_timeout: @open_timeout
rescue Errno::ETIMEDOUT #raise Net:OpenTimeout instead for compatibility with previous versions
raise Net::OpenTimeout, "Timeout to open TCP connection to "\
"#{host}:#{port} (exceeds #{@open_timeout} seconds)"
end
end
}
end
private :open_socket

Expand Down