1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Do not raise an exception on a closed DRb socket

This rescues some exceptions that could happen with a closed or
shutdown DRb socket. This can prevent the server from
exiting if an client socket is closed directly after it is
accepted.

Fixes [Bug #8039]
This commit is contained in:
Jeremy Evans 2019-08-08 15:44:26 -07:00
parent 50b8033d6b
commit 567e312d1f
Notes: git 2019-10-17 04:51:34 +09:00
2 changed files with 17 additions and 0 deletions

View file

@ -1024,6 +1024,8 @@ module DRb
def set_sockopt(soc) # :nodoc:
soc.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
rescue IOError, Errno::ECONNRESET, Errno::EINVAL
# closed/shutdown socket, ignore error
end
end

View file

@ -327,4 +327,19 @@ class TestBug4409 < Test::Unit::TestCase
end
end
class TestDRbTCP < Test::Unit::TestCase
def test_immediate_close
server = DRb::DRbServer.new('druby://:0')
host, port, = DRb::DRbTCPSocket.send(:parse_uri, server.uri)
socket = TCPSocket.open host, port
socket.shutdown
socket.close
client = DRb::DRbTCPSocket.new(server.uri, socket)
assert client
client.close
server.stop_service
server.thread.join
end
end
end