diff options
author | glass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-12-31 00:46:07 +0000 |
---|---|---|
committer | glass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-12-31 00:46:07 +0000 |
commit | 69a1db96fe63ff3071cb3d272675a1d0470aab01 (patch) | |
tree | ef9aca397ca57fd1376d44309a54e69717a0c1cc /lib/net/ftp.rb | |
parent | f964fd3fa5070b95cb412cb529b47e168c0af25a (diff) |
lib/net/http.rb: use connect_timeout instead of Timeout
lib/net/pop.rb: ditto
lib/net/ftp.rb: ditto
lib/net/smtp.rb: ditto
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66659 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/net/ftp.rb')
-rw-r--r-- | lib/net/ftp.rb | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/net/ftp.rb b/lib/net/ftp.rb index e68d825dcf..ae0e8d4db1 100644 --- a/lib/net/ftp.rb +++ b/lib/net/ftp.rb @@ -329,14 +329,18 @@ 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 + return Timeout.timeout(@open_timeout, OpenTimeout) { SOCKSSocket.open(host, port) - else - Socket.tcp(host, port) + } + else + begin + return Socket.tcp(host, port, connect_timeout: @open_timeout) + rescue Errno::ETIMEDOUT + raise OpenTimeout, "execution expired" end - } + end end private :open_socket |