diff options
-rw-r--r-- | lib/net/ftp.rb | 17 | ||||
-rw-r--r-- | version.h | 2 |
2 files changed, 12 insertions, 7 deletions
diff --git a/lib/net/ftp.rb b/lib/net/ftp.rb index 5e3e181c16..9e57cb363f 100644 --- a/lib/net/ftp.rb +++ b/lib/net/ftp.rb @@ -330,14 +330,19 @@ module Net # SOCKS_SERVER, then a SOCKSSocket is returned, else a Socket is # returned. def open_socket(host, port) # :nodoc: - return Timeout.timeout(@open_timeout, OpenTimeout) { - if defined? SOCKSSocket and ENV["SOCKS_SERVER"] - @passive = true + if defined? SOCKSSocket and ENV["SOCKS_SERVER"] + @passive = true + Timeout.timeout(@open_timeout, OpenTimeout) do 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 @@ -12,7 +12,7 @@ # define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR #define RUBY_VERSION_TEENY 2 #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR -#define RUBY_PATCHLEVEL 96 +#define RUBY_PATCHLEVEL 97 #define RUBY_RELEASE_YEAR 2021 #define RUBY_RELEASE_MONTH 6 |