From 2d302dfd40ee9a4b3183415b19dbc22cf9106ba3 Mon Sep 17 00:00:00 2001 From: kazu Date: Fri, 22 Aug 2008 11:12:06 +0000 Subject: [PATCH] * 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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18777 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 10 ++++++++++ lib/net/imap.rb | 14 +++++++++----- lib/webrick/server.rb | 12 ++++++++++-- test/openssl/test_ssl.rb | 9 ++++++++- 4 files changed, 37 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2c02220eb0..2980450b5b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Fri Aug 22 20:06:46 2008 Kazuhiro NISHIYAMA + + * 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 * lib/date.rb: no need to require the "lib/rational.rb" any more. diff --git a/lib/net/imap.rb b/lib/net/imap.rb index 64011e69cc..e6ffa3b1e0 100644 --- a/lib/net/imap.rb +++ b/lib/net/imap.rb @@ -288,11 +288,15 @@ module Net # 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 diff --git a/lib/webrick/server.rb b/lib/webrick/server.rb index 68501517c1..d0b6f2b693 100644 --- a/lib/webrick/server.rb +++ b/lib/webrick/server.rb @@ -130,9 +130,17 @@ module WEBrick 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 diff --git a/test/openssl/test_ssl.rb b/test/openssl/test_ssl.rb index eadff733a6..ea959892f3 100644 --- a/test/openssl/test_ssl.rb +++ b/test/openssl/test_ssl.rb @@ -129,7 +129,14 @@ class OpenSSL::TestSSL < Test::Unit::TestCase 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?