diff --git a/lib/drb/drb.rb b/lib/drb/drb.rb index 25642dd939..9b4d675096 100644 --- a/lib/drb/drb.rb +++ b/lib/drb/drb.rb @@ -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 diff --git a/test/drb/test_drb.rb b/test/drb/test_drb.rb index 4e8f5cb0ec..b4399573aa 100644 --- a/test/drb/test_drb.rb +++ b/test/drb/test_drb.rb @@ -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