ruby-changes:44807
From: shugo <ko1@a...>
Date: Wed, 23 Nov 2016 09:34:29 +0900 (JST)
Subject: [ruby-changes:44807] shugo:r56880 (trunk): Disconnect immediately even if Net::FTP#close is called without quit.
shugo 2016-11-23 09:34:13 +0900 (Wed, 23 Nov 2016) New Revision: 56880 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56880 Log: 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. Modified files: trunk/lib/net/ftp.rb Index: lib/net/ftp.rb =================================================================== --- lib/net/ftp.rb (revision 56879) +++ lib/net/ftp.rb (revision 56880) @@ -1443,16 +1443,32 @@ module Net https://github.com/ruby/ruby/blob/trunk/lib/net/ftp.rb#L1443 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: -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/