Skip to content

Commit

Permalink
Do not remove pre-existing socket after USR2+TERM (#2816) (#2817)
Browse files Browse the repository at this point in the history
The issue was that inherited socket was added to the @unix_paths list even if it was pre-existing.
Test added.

Closed #2816.
  • Loading branch information
khustochka authored and nateberkopec committed Aug 22, 2022
1 parent c36d644 commit 3eb994e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/puma/binder.rb
Expand Up @@ -189,7 +189,7 @@ def parse(binds, logger, log_msg = 'Listening')
end

if fd = @inherited_fds.delete(str)
@unix_paths << path unless abstract
@unix_paths << path unless abstract || File.exist?(path)
io = inherit_unix_listener path, fd
logger.log "* Inherited #{str}"
elsif sock = @activated_sockets.delete([ :unix, path ]) ||
Expand Down
20 changes: 20 additions & 0 deletions test/test_integration_cluster.rb
Expand Up @@ -43,6 +43,26 @@ def test_pre_existing_unix
end
end

def test_pre_existing_unix_stop_after_restart
skip_unless :unix

File.open(@bind_path, mode: 'wb') { |f| f.puts 'pre existing' }

cli_server "-w #{workers} -q test/rackup/sleep_step.ru", unix: :unix
connection = connect(nil, unix: true)
restart_server connection

connect(nil, unix: true)
stop_server

assert File.exist?(@bind_path)

ensure
if UNIX_SKT_EXIST
File.unlink @bind_path if File.exist? @bind_path
end
end

def test_siginfo_thread_print
skip_unless_signal_exist? :INFO

Expand Down

0 comments on commit 3eb994e

Please sign in to comment.