summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/net/imap.rb14
-rw-r--r--lib/webrick/server.rb12
2 files changed, 19 insertions, 7 deletions
diff --git a/lib/net/imap.rb b/lib/net/imap.rb
index 64011e69ccf..e6ffa3b1e07 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 68501517c14..d0b6f2b693a 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