* lib/ftp/ftp.rb (Net::FTP#close): restore original read_timeout.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35236 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2012-04-04 04:10:58 +00:00
parent f0cd9107df
commit 7865005fa1
3 changed files with 14 additions and 5 deletions

View File

@ -1,3 +1,7 @@
Wed Apr 4 13:06:39 2012 NARUSE, Yui <naruse@ruby-lang.org>
* lib/ftp/ftp.rb (Net::FTP#close): restore original read_timeout.
Wed Apr 4 10:33:31 2012 NARUSE, Yui <naruse@ruby-lang.org>
* lib/ftp/ftp.rb (Net::FTP#close): ignore exceptions from shutdown and

View File

@ -933,10 +933,14 @@ module Net
#
def close
if @sock and not @sock.closed?
@sock.shutdown(Socket::SHUT_WR) rescue nil
@sock.read_timeout = 3
@sock.read rescue nil
@sock.close
begin
@sock.shutdown(Socket::SHUT_WR) rescue nil
orig, self.read_timeout = self.read_timeout, 3
@sock.read rescue nil
ensure
@sock.close
self.read_timeout = orig
end
end
end

View File

@ -229,7 +229,8 @@ class FTPTest < Test::Unit::TestCase
assert_equal("TYPE I\r\n", commands.shift)
assert_equal(nil, commands.shift)
ensure
ftp.close if ftp
ftp.close
assert_equal(0.2, ftp.read_timeout)
end
ensure
server.close