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

ruby-changes:7258

From: kazu <ko1@a...>
Date: Fri, 22 Aug 2008 20:15:31 +0900 (JST)
Subject: [ruby-changes:7258] Ruby:r18777 (trunk): * lib/webrick/server.rb (WEBrick::GenericServer#shutdown):

kazu	2008-08-22 20:12:06 +0900 (Fri, 22 Aug 2008)

  New Revision: 18777

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

  Log:
    * lib/webrick/server.rb (WEBrick::GenericServer#shutdown):
      rescue Errno::ENOTCONN and close. [ruby-dev:35896]
    
    * test/openssl/test_ssl.rb (OpenSSL#start_server): ditto.
      [ruby-dev:35897]
    
    * lib/net/imap.rb (Net::IMAP#disconnect): ditto. [ruby-dev:35898]

  Modified files:
    trunk/ChangeLog
    trunk/lib/net/imap.rb
    trunk/lib/webrick/server.rb
    trunk/test/openssl/test_ssl.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 18776)
+++ ChangeLog	(revision 18777)
@@ -1,3 +1,13 @@
+Fri Aug 22 20:06:46 2008  Kazuhiro NISHIYAMA  <zn@m...>
+
+	* lib/webrick/server.rb (WEBrick::GenericServer#shutdown):
+	  rescue Errno::ENOTCONN and close. [ruby-dev:35896]
+
+	* test/openssl/test_ssl.rb (OpenSSL#start_server): ditto.
+	  [ruby-dev:35897]
+
+	* lib/net/imap.rb (Net::IMAP#disconnect): ditto. [ruby-dev:35898]
+
 Fri Aug 22 19:58:27 2008  Tadayoshi Funaba  <tadf@d...>
 
 	* lib/date.rb: no need to require the "lib/rational.rb" any more.
Index: lib/webrick/server.rb
===================================================================
--- lib/webrick/server.rb	(revision 18776)
+++ lib/webrick/server.rb	(revision 18777)
@@ -130,9 +130,17 @@
           addr = s.addr
           @logger.debug("close TCPSocket(#{addr[2]}, #{addr[1]})")
         end
-        s.shutdown
-        unless @config[:ShutdownSocketWithoutClose]
+        begin
+          s.shutdown
+        rescue Errno::ENOTCONN
+          # when `Errno::ENOTCONN: Socket is not connected' on some platforms,
+          # call #close instead of #shutdown.
+          # (ignore @config[:ShutdownSocketWithoutClose])
           s.close
+        else
+          unless @config[:ShutdownSocketWithoutClose]
+            s.close
+          end
         end
       }
       @listeners.clear
Index: lib/net/imap.rb
===================================================================
--- lib/net/imap.rb	(revision 18776)
+++ lib/net/imap.rb	(revision 18777)
@@ -288,11 +288,15 @@
     # Disconnects from the server.
     def disconnect
       begin
-        # try to call SSL::SSLSocket#io.
-        @sock.io.shutdown
-      rescue NoMethodError
-        # @sock is not an SSL::SSLSocket.
-        @sock.shutdown
+        begin
+          # try to call SSL::SSLSocket#io.
+          @sock.io.shutdown
+        rescue NoMethodError
+          # @sock is not an SSL::SSLSocket.
+          @sock.shutdown
+        end
+      rescue Errno::ENOTCONN
+        # ignore `Errno::ENOTCONN: Socket is not connected' on some platforms.
       end
       @receiver_thread.join
       @sock.close
Index: test/openssl/test_ssl.rb
===================================================================
--- test/openssl/test_ssl.rb	(revision 18776)
+++ test/openssl/test_ssl.rb	(revision 18777)
@@ -129,7 +129,14 @@
       block.call(server, port.to_i)
     ensure
       begin
-        tcps.shutdown if (tcps)
+        begin
+          tcps.shutdown
+        rescue Errno::ENOTCONN
+          # when `Errno::ENOTCONN: Socket is not connected' on some platforms,
+          # call #close instead of #shutdown.
+          tcps.close
+          tcps = nil
+        end if (tcps)
         if (server)
           server.join(5)
           if server.alive?

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

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