From 69d4c6391d958dc43d409417350d4f7ecc259814 Mon Sep 17 00:00:00 2001 From: MSP-Greg Date: Sat, 14 Jul 2018 20:09:58 -0500 Subject: [PATCH] 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 --- lib/puma/binder.rb | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/puma/binder.rb b/lib/puma/binder.rb index bcaeeec0..372a98e5 100644 --- a/lib/puma/binder.rb +++ b/lib/puma/binder.rb @@ -90,19 +90,19 @@ module Puma case uri.scheme when "tcp" if fd = @inherited_fds.delete(str) - logger.log "* Inherited #{str}" io = inherit_tcp_listener uri.host, uri.port, fd + logger.log "* Inherited #{str}" elsif sock = @activated_sockets.delete([ :tcp, uri.host, uri.port ]) - logger.log "* Activated #{str}" io = inherit_tcp_listener uri.host, uri.port, sock + logger.log "* Activated #{str}" else params = Util.parse_query uri.query opt = params.key?('low_latency') bak = params.fetch('backlog', 1024).to_i - logger.log "* Listening on #{str}" io = add_tcp_listener uri.host, uri.port, opt, bak + logger.log "* Listening on #{str}" end @listeners << [str, io] if io @@ -110,14 +110,12 @@ module Puma path = "#{uri.host}#{uri.path}".gsub("%20", " ") if fd = @inherited_fds.delete(str) - logger.log "* Inherited #{str}" io = inherit_unix_listener path, fd + logger.log "* Inherited #{str}" elsif sock = @activated_sockets.delete([ :unix, path ]) - logger.log "* Activated #{str}" io = inherit_unix_listener path, sock + logger.log "* Activated #{str}" else - logger.log "* Listening on #{str}" - umask = nil mode = nil backlog = 1024 @@ -139,6 +137,7 @@ module Puma end io = add_unix_listener path, umask, mode, backlog + logger.log "* Listening on #{str}" end @listeners << [str, io] @@ -204,11 +203,11 @@ module Puma logger.log "* Inherited #{str}" io = inherit_ssl_listener fd, ctx elsif sock = @activated_sockets.delete([ :tcp, uri.host, uri.port ]) - logger.log "* Activated #{str}" io = inherit_ssl_listener sock, ctx + logger.log "* Activated #{str}" else - logger.log "* Listening on #{str}" io = add_ssl_listener uri.host, uri.port, ctx + logger.log "* Listening on #{str}" end @listeners << [str, io] if io