Skip to content

Commit

Permalink
rm unix_paths
Browse files Browse the repository at this point in the history
  • Loading branch information
nateberkopec committed Sep 26, 2019
1 parent 56a67be commit 4da434a
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions lib/puma/binder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ def initialize(events)
@bindings = []
@inherited_fds = {}
@activated_sockets = {}
@unix_paths = []

@proto_env = {
"rack.version".freeze => RACK_VERSION,
Expand Down Expand Up @@ -99,11 +98,11 @@ def env(sock)
end

def close
bindings.each(&:close)
@bindings.each(&:close)
end

def bound_ios
bindings.map(&:io)
@bindings.map(&:io)
end

def import_from_env
Expand Down Expand Up @@ -328,7 +327,7 @@ def add_tcp_listener(host, port, optimize_for_latency=true, backlog=1024)
s.listen backlog
@connected_port = s.addr[1]

bindings << Binding.new(s)
@bindings << Binding.new(s)
s
end

Expand All @@ -341,7 +340,7 @@ def inherit_tcp_listener(host, port, fd)
s = TCPServer.for_fd(fd)
end

bindings << Binding.new(s)
@bindings << Binding.new(s)
s
end

Expand Down Expand Up @@ -372,7 +371,7 @@ def add_ssl_listener(host, port, ctx,
env[HTTPS_KEY] = HTTPS
@envs[ssl] = env

bindings << Binding.new(ssl.to_io, ssl)
@bindings << Binding.new(ssl.to_io, ssl)
s
end

Expand All @@ -391,15 +390,13 @@ def inherit_ssl_listener(fd, ctx)
env[HTTPS_KEY] = HTTPS
@envs[ssl] = env

bindings << Binding.new(ssl.to_io, ssl)
@bindings << Binding.new(ssl.to_io, ssl)
s
end

# 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

# Let anyone connect by default
umask ||= 0

Expand All @@ -419,7 +416,7 @@ def add_unix_listener(path, umask=nil, mode=nil, backlog=1024)

s = UNIXServer.new(path)
s.listen backlog
bindings << Binding.new(s)
@bindings << Binding.new(s)
ensure
File.umask old_mask
end
Expand All @@ -436,14 +433,12 @@ def add_unix_listener(path, umask=nil, mode=nil, backlog=1024)
end

def inherit_unix_listener(path, fd)
@unix_paths << path

if fd.kind_of? TCPServer
s = fd
else
s = UNIXServer.for_fd fd
end
bindings << Binding.new(s)
@bindings << Binding.new(s)

env = @proto_env.dup
env[REMOTE_ADDR] = "127.0.0.1"
Expand All @@ -453,15 +448,15 @@ def inherit_unix_listener(path, fd)
end

def close_listeners
bindings.each do |binder|
@bindings.each do |binder|
binder.close
next unless binder.unix?
File.unlink(binder.io.path)
end
end

def close_unix_paths
@unix_paths.each { |up| File.unlink(up) if File.exist? up }
binders.select(&:unix?).each { |b| File.unlink(b.path) if File.exist?(b.path) }
end

def redirects_for_restart
Expand Down

0 comments on commit 4da434a

Please sign in to comment.