summaryrefslogtreecommitdiff
path: root/lib/net/ftp.rb
diff options
context:
space:
mode:
authorshugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-23 00:34:13 +0000
committershugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-23 00:34:13 +0000
commita7a1391fc927d339c9ce6de976c2655d9e2b75e2 (patch)
treef3bd810bf3217da29d7724cef480a7a81785ad2e /lib/net/ftp.rb
parente50266f299758a49d8933f4023803470c5f09943 (diff)
Disconnect immediately even if Net::FTP#close is called without quit.
In that case, BufferedSSLSocket#read in FTP#close exceeded timeout because BufferedSSLSocket#shutdown did nothing. So BufferedIO#rbuf_fill is overridden in BufferedSSLSocket to raise an EOFError if the connection is shut down. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56880 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/net/ftp.rb')
-rw-r--r--lib/net/ftp.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/net/ftp.rb b/lib/net/ftp.rb
index 9f2f76fb1d..e2bf1b29fc 100644
--- a/lib/net/ftp.rb
+++ b/lib/net/ftp.rb
@@ -1443,16 +1443,32 @@ module Net
if defined?(OpenSSL::SSL::SSLSocket)
class BufferedSSLSocket < BufferedSocket
+ def initialize(*args)
+ super
+ @is_shutdown = false
+ end
+
def shutdown(*args)
# SSL_shutdown() will be called from SSLSocket#close, and
# SSL_shutdonw() will send the "close notify" alert to the peer,
# so shutdown(2) should not be called.
+ @is_shutdown = true
end
def send(mesg, flags, dest = nil)
# Ignore flags and dest.
@io.write(mesg)
end
+
+ private
+
+ def rbuf_fill
+ if @is_shutdown
+ raise EOFError, "shutdown has been called"
+ else
+ super
+ end
+ end
end
end
# :startdoc: