From 7c31c2738c7d02e5a9ac6167c650cb8a5411321d Mon Sep 17 00:00:00 2001 From: normal Date: Sat, 25 Aug 2018 02:32:15 +0000 Subject: [PATCH] drb: close graceful shutdown pipe before socket Closing a listen socket while entering select(2) may trigger IOError or even deadlock because another thread may give the file descriptor to another file description; meaning the kernel can wait on the wrong description. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64532 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/drb/drb.rb | 1 + lib/drb/unix.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/drb/drb.rb b/lib/drb/drb.rb index 36b2b1ade4..a20ee1f143 100644 --- a/lib/drb/drb.rb +++ b/lib/drb/drb.rb @@ -953,6 +953,7 @@ module DRb # returned by #open or by #accept, then it closes this particular # client-server session. def close + shutdown if @socket @socket.close @socket = nil diff --git a/lib/drb/unix.rb b/lib/drb/unix.rb index adc38ff591..7dcf2daaf8 100644 --- a/lib/drb/unix.rb +++ b/lib/drb/unix.rb @@ -95,6 +95,7 @@ module DRb public def close return unless @socket + shutdown # DRbProtocol#shutdown path = @socket.path if @server_mode @socket.close File.unlink(path) if @server_mode