diff options
Diffstat (limited to 'lib/webrick/server.rb')
-rw-r--r-- | lib/webrick/server.rb | 12 |
1 files changed, 10 insertions, 2 deletions
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 |