[前][次][番号順一覧][スレッド一覧]

ruby-changes:23186

From: naruse <ko1@a...>
Date: Wed, 4 Apr 2012 13:11:13 +0900 (JST)
Subject: [ruby-changes:23186] naruse:r35236 (trunk): * lib/ftp/ftp.rb (Net::FTP#close): restore original read_timeout.

naruse	2012-04-04 13:10:58 +0900 (Wed, 04 Apr 2012)

  New Revision: 35236

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=35236

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

  Modified files:
    trunk/ChangeLog
    trunk/lib/net/ftp.rb
    trunk/test/net/ftp/test_ftp.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 35235)
+++ ChangeLog	(revision 35236)
@@ -1,3 +1,7 @@
+Wed Apr  4 13:06:39 2012  NARUSE, Yui  <naruse@r...>
+
+	* lib/ftp/ftp.rb (Net::FTP#close): restore original read_timeout.
+
 Wed Apr  4 10:33:31 2012  NARUSE, Yui  <naruse@r...>
 
 	* lib/ftp/ftp.rb (Net::FTP#close): ignore exceptions from shutdown and
Index: lib/net/ftp.rb
===================================================================
--- lib/net/ftp.rb	(revision 35235)
+++ lib/net/ftp.rb	(revision 35236)
@@ -933,10 +933,14 @@
     #
     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
 
Index: test/net/ftp/test_ftp.rb
===================================================================
--- test/net/ftp/test_ftp.rb	(revision 35235)
+++ test/net/ftp/test_ftp.rb	(revision 35236)
@@ -229,7 +229,8 @@
         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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]