1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00

binder.rb - move logger.log calls after adding listeners

Other threads may be writing to sockets based on logger.log calls, so they must be after the listeners are available
This commit is contained in:
MSP-Greg 2018-07-14 20:09:58 -05:00
parent d639760c24
commit 69d4c6391d

View file

@ -90,19 +90,19 @@ module Puma
case uri.scheme case uri.scheme
when "tcp" when "tcp"
if fd = @inherited_fds.delete(str) if fd = @inherited_fds.delete(str)
logger.log "* Inherited #{str}"
io = inherit_tcp_listener uri.host, uri.port, fd io = inherit_tcp_listener uri.host, uri.port, fd
logger.log "* Inherited #{str}"
elsif sock = @activated_sockets.delete([ :tcp, uri.host, uri.port ]) elsif sock = @activated_sockets.delete([ :tcp, uri.host, uri.port ])
logger.log "* Activated #{str}"
io = inherit_tcp_listener uri.host, uri.port, sock io = inherit_tcp_listener uri.host, uri.port, sock
logger.log "* Activated #{str}"
else else
params = Util.parse_query uri.query params = Util.parse_query uri.query
opt = params.key?('low_latency') opt = params.key?('low_latency')
bak = params.fetch('backlog', 1024).to_i bak = params.fetch('backlog', 1024).to_i
logger.log "* Listening on #{str}"
io = add_tcp_listener uri.host, uri.port, opt, bak io = add_tcp_listener uri.host, uri.port, opt, bak
logger.log "* Listening on #{str}"
end end
@listeners << [str, io] if io @listeners << [str, io] if io
@ -110,14 +110,12 @@ module Puma
path = "#{uri.host}#{uri.path}".gsub("%20", " ") path = "#{uri.host}#{uri.path}".gsub("%20", " ")
if fd = @inherited_fds.delete(str) if fd = @inherited_fds.delete(str)
logger.log "* Inherited #{str}"
io = inherit_unix_listener path, fd io = inherit_unix_listener path, fd
logger.log "* Inherited #{str}"
elsif sock = @activated_sockets.delete([ :unix, path ]) elsif sock = @activated_sockets.delete([ :unix, path ])
logger.log "* Activated #{str}"
io = inherit_unix_listener path, sock io = inherit_unix_listener path, sock
logger.log "* Activated #{str}"
else else
logger.log "* Listening on #{str}"
umask = nil umask = nil
mode = nil mode = nil
backlog = 1024 backlog = 1024
@ -139,6 +137,7 @@ module Puma
end end
io = add_unix_listener path, umask, mode, backlog io = add_unix_listener path, umask, mode, backlog
logger.log "* Listening on #{str}"
end end
@listeners << [str, io] @listeners << [str, io]
@ -204,11 +203,11 @@ module Puma
logger.log "* Inherited #{str}" logger.log "* Inherited #{str}"
io = inherit_ssl_listener fd, ctx io = inherit_ssl_listener fd, ctx
elsif sock = @activated_sockets.delete([ :tcp, uri.host, uri.port ]) elsif sock = @activated_sockets.delete([ :tcp, uri.host, uri.port ])
logger.log "* Activated #{str}"
io = inherit_ssl_listener sock, ctx io = inherit_ssl_listener sock, ctx
logger.log "* Activated #{str}"
else else
logger.log "* Listening on #{str}"
io = add_ssl_listener uri.host, uri.port, ctx io = add_ssl_listener uri.host, uri.port, ctx
logger.log "* Listening on #{str}"
end end
@listeners << [str, io] if io @listeners << [str, io] if io