ruby-changes:58285
From: Jeremy <ko1@a...>
Date: Thu, 17 Oct 2019 04:51:28 +0900 (JST)
Subject: [ruby-changes:58285] 567e312d1f (master): Do not raise an exception on a closed DRb socket
https://git.ruby-lang.org/ruby.git/commit/?id=567e312d1f From 567e312d1f56c27ecb4fa20deac4311f05ee5507 Mon Sep 17 00:00:00 2001 From: Jeremy Evans <code@j...> Date: Thu, 8 Aug 2019 15:44:26 -0700 Subject: 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] diff --git a/lib/drb/drb.rb b/lib/drb/drb.rb index 25642dd..9b4d675 100644 --- a/lib/drb/drb.rb +++ b/lib/drb/drb.rb @@ -1024,6 +1024,8 @@ module DRb https://github.com/ruby/ruby/blob/trunk/lib/drb/drb.rb#L1024 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 4e8f5cb..b439957 100644 --- a/test/drb/test_drb.rb +++ b/test/drb/test_drb.rb @@ -327,4 +327,19 @@ class TestBug4409 < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/drb/test_drb.rb#L327 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 -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/