From 1a484d8d1c4007572cea394279109246de4395da Mon Sep 17 00:00:00 2001 From: MSP-Greg Date: Tue, 1 Oct 2019 08:50:38 -0500 Subject: [PATCH] Fix Binder @unix_paths handling 1. Move removal to launcher from single and cluster. 2. @unix_paths only contains files that Puma creates (pre-existing files are not) --- lib/puma/binder.rb | 7 ++++--- lib/puma/cluster.rb | 1 - lib/puma/launcher.rb | 5 +---- lib/puma/single.rb | 1 - 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/puma/binder.rb b/lib/puma/binder.rb index a5e48c8c..e1156d6d 100644 --- a/lib/puma/binder.rb +++ b/lib/puma/binder.rb @@ -361,7 +361,7 @@ module Puma # Tell the server to listen on +path+ as a UNIX domain socket. # def add_unix_listener(path, umask=nil, mode=nil, backlog=1024) - @unix_paths << path + @unix_paths << path unless File.exist? path # Let anyone connect by default umask ||= 0 @@ -399,7 +399,7 @@ module Puma end def inherit_unix_listener(path, fd) - @unix_paths << path + @unix_paths << path unless File.exist? path if fd.kind_of? TCPServer s = fd @@ -420,7 +420,8 @@ module Puma io.close uri = URI.parse(l) next unless uri.scheme == 'unix' - File.unlink("#{uri.host}#{uri.path}") + unix_path = "#{uri.host}#{uri.path}" + File.unlink unix_path if @unix_paths.include? unix_path end end diff --git a/lib/puma/cluster.rb b/lib/puma/cluster.rb index 5b84f668..fb9b63fa 100644 --- a/lib/puma/cluster.rb +++ b/lib/puma/cluster.rb @@ -529,7 +529,6 @@ module Puma @suicide_pipe.close read.close @wakeup.close - @launcher.close_binder_unix_paths end end diff --git a/lib/puma/launcher.rb b/lib/puma/launcher.rb index 4f896c85..2a0cd9be 100644 --- a/lib/puma/launcher.rb +++ b/lib/puma/launcher.rb @@ -184,6 +184,7 @@ module Puma when :exit # nothing end + @binder.close_unix_paths end # Return which tcp port the launcher is using, if it's using TCP @@ -204,10 +205,6 @@ module Puma @binder.close_listeners end - def close_binder_unix_paths - @binder.close_unix_paths - end - private # If configured, write the pid of the current process out diff --git a/lib/puma/single.rb b/lib/puma/single.rb index 1b5a56e7..a1673a8e 100644 --- a/lib/puma/single.rb +++ b/lib/puma/single.rb @@ -118,7 +118,6 @@ module Puma rescue Interrupt # Swallow it end - @launcher.close_binder_unix_paths end end end