diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | lib/net/ftp.rb | 12 | ||||
-rw-r--r-- | test/net/ftp/test_ftp.rb | 3 |
3 files changed, 14 insertions, 5 deletions
@@ -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 diff --git a/lib/net/ftp.rb b/lib/net/ftp.rb index 3dc1e2efb4..5be2981dd0 100644 --- a/lib/net/ftp.rb +++ b/lib/net/ftp.rb @@ -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 diff --git a/test/net/ftp/test_ftp.rb b/test/net/ftp/test_ftp.rb index cee4649493..8ea0234762 100644 --- a/test/net/ftp/test_ftp.rb +++ b/test/net/ftp/test_ftp.rb @@ -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 |