Skip to content

Commit f55e9d5

Browse files
committed
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
1 parent 7efa5f9 commit f55e9d5

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

lib/net/ftp.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,16 +1443,32 @@ def readline
14431443

14441444
if defined?(OpenSSL::SSL::SSLSocket)
14451445
class BufferedSSLSocket < BufferedSocket
1446+
def initialize(*args)
1447+
super
1448+
@is_shutdown = false
1449+
end
1450+
14461451
def shutdown(*args)
14471452
# SSL_shutdown() will be called from SSLSocket#close, and
14481453
# SSL_shutdonw() will send the "close notify" alert to the peer,
14491454
# so shutdown(2) should not be called.
1455+
@is_shutdown = true
14501456
end
14511457

14521458
def send(mesg, flags, dest = nil)
14531459
# Ignore flags and dest.
14541460
@io.write(mesg)
14551461
end
1462+
1463+
private
1464+
1465+
def rbuf_fill
1466+
if @is_shutdown
1467+
raise EOFError, "shutdown has been called"
1468+
else
1469+
super
1470+
end
1471+
end
14561472
end
14571473
end
14581474
# :startdoc:

0 commit comments

Comments
 (0)