Skip to content

Commit

Permalink
unlink UNIXSocket files, fix Binder#close (#1970)
Browse files Browse the repository at this point in the history
  • Loading branch information
MSP-Greg authored and nateberkopec committed Sep 18, 2019
1 parent 7e704b5 commit db74ad4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
12 changes: 4 additions & 8 deletions lib/puma/binder.rb
Expand Up @@ -50,14 +50,6 @@ def env(sock)

def close
@ios.each { |i| i.close }
@unix_paths.each do |i|
# Errno::ENOENT is intermittently raised
begin
unix_socket = UNIXSocket.new i
unix_socket.close
rescue Errno::ENOENT
end
end
end

def import_from_env
Expand Down Expand Up @@ -431,6 +423,10 @@ def close_listeners
end
end

def close_unix_paths
@unix_paths.each { |up| File.unlink(up) if File.exist? up }
end

def redirects_for_restart
redirects = {:close_others => true}
@listeners.each_with_index do |(l, io), i|
Expand Down
1 change: 1 addition & 0 deletions lib/puma/cluster.rb
Expand Up @@ -527,6 +527,7 @@ def run
@suicide_pipe.close
read.close
@wakeup.close
@launcher.close_binder_unix_paths
end
end

Expand Down
4 changes: 4 additions & 0 deletions lib/puma/launcher.rb
Expand Up @@ -220,6 +220,10 @@ def close_binder_listeners
@binder.close_listeners
end

def close_binder_unix_paths
@binder.close_unix_paths
end

private

def reload_worker_directory
Expand Down
1 change: 1 addition & 0 deletions lib/puma/single.rb
Expand Up @@ -118,6 +118,7 @@ def run
rescue Interrupt
# Swallow it
end
@launcher.close_binder_unix_paths
end
end
end

0 comments on commit db74ad4

Please sign in to comment.