From ae6a506029e5a9ebb851c5fea63c066894ef47ea Mon Sep 17 00:00:00 2001 From: MSP-Greg Date: Sat, 6 Mar 2021 11:24:00 -0600 Subject: [PATCH] Don't close systemd activated socket on pumactl restart (#2563) Closes #2504 --- History.md | 9 +++++++++ lib/puma/binder.rb | 18 +++++++++++------- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/History.md b/History.md index f5adb8b7..4d841f59 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,12 @@ +## Master + +* Features + * Your feature goes here (#Github Number) + +* Bugfixes + * Your bugfix goes here (#Github Number) + * Don't close systemd activated socket on pumactl restart (#2563, #2504) + ## 5.2.2 / 2021-02-22 * Bugfixes diff --git a/lib/puma/binder.rb b/lib/puma/binder.rb index e59603ca..13fbec06 100644 --- a/lib/puma/binder.rb +++ b/lib/puma/binder.rb @@ -258,14 +258,18 @@ module Puma end # Also close any unused activated sockets - @activated_sockets.each do |key, sock| - logger.log "* Closing unused activated socket: #{key.join ':'}" - begin - sock.close - rescue SystemCallError + unless @activated_sockets.empty? + fds = @ios.map(&:to_i) + @activated_sockets.each do |key, sock| + next if fds.include? sock.to_i + logger.log "* Closing unused activated socket: #{key.first}://#{key[1..-1].join ':'}" + begin + sock.close + rescue SystemCallError + end + # We have to unlink a unix socket path that's not being used + File.unlink key[1] if key.first == :unix end - # We have to unlink a unix socket path that's not being used - File.unlink key[1] if key[0] == :unix end end