Skip to content

Commit

Permalink
default unix backlog depth to 1024, fixes puma#1449
Browse files Browse the repository at this point in the history
  • Loading branch information
eprothro committed Nov 28, 2017
1 parent a85b902 commit 5fefa31
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/puma/binder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def parse(binds, logger)

umask = nil
mode = nil
backlog = nil
backlog = 1024

if uri.query
params = Util.parse_query uri.query
Expand Down Expand Up @@ -344,7 +344,7 @@ def inherit_ssl_listener(fd, ctx)

# Tell the server to listen on +path+ as a UNIX domain socket.
#
def add_unix_listener(path, umask=nil, mode=nil, backlog=nil)
def add_unix_listener(path, umask=nil, mode=nil, backlog=1024)
@unix_paths << path

# Let anyone connect by default
Expand All @@ -365,7 +365,7 @@ def add_unix_listener(path, umask=nil, mode=nil, backlog=nil)
end

s = UNIXServer.new(path)
s.listen backlog if backlog
s.listen backlog
@ios << s
ensure
File.umask old_mask
Expand Down
17 changes: 15 additions & 2 deletions lib/puma/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,22 @@ def load(file)
@options[:config_files] << file
end

# Bind the server to +url+. tcp:// and unix:// are the only accepted
# protocols.
# Adds a binding for the server to +url+. tcp://, unix://, and ssl:// are the only accepted
# protocols. Use query parameters within the url to specify options.
#
# @note multiple urls can be bound to, calling `bind` does not overwrite previous bindings.
#
# @example Explicitly the socket backlog depth (default is 1024)
# bind('unix:///var/run/puma.sock?backlog=2048')
#
# @example Set up ssl cert
# bind('ssl://127.0.0.1:9292?key=key.key&cert=cert.pem')
#
# @example Prefer low-latency over higher throughput (via `Socket::TCP_NODELAY`)
# bind('tcp://0.0.0.0:9292?low_latency=true')
#
# @example Set socket permissions
# bind('unix:///var/run/puma.sock?umask=0111')
def bind(url)
@options[:binds] ||= []
@options[:binds] << url
Expand Down

0 comments on commit 5fefa31

Please sign in to comment.