From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id EB2F71F49B for ; Sun, 22 Mar 2020 08:58:49 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 2/2] daemon: unlink .oldbin PID file correctly Date: Sun, 22 Mar 2020 08:58:49 +0000 Message-Id: <20200322085849.14360-3-e@yhbt.net> In-Reply-To: <20200322085849.14360-1-e@yhbt.net> References: <20200322085849.14360-1-e@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: We need to track the PID file having ".oldbin" appended to it while a SIGUSR2 upgrade is in progress and ensure it is unlinked on SIGQUIT. --- lib/PublicInbox/Daemon.pm | 4 ++-- t/httpd-unix.t | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/PublicInbox/Daemon.pm b/lib/PublicInbox/Daemon.pm index 3d582e35..4ff7cad4 100644 --- a/lib/PublicInbox/Daemon.pm +++ b/lib/PublicInbox/Daemon.pm @@ -247,7 +247,7 @@ sub daemonize () { write_pid($pid_file); # for ->DESTROY: - bless { pid => $$, pid_file => $pid_file }, __PACKAGE__; + bless { pid => $$, pid_file => \$pid_file }, __PACKAGE__; } sub worker_quit { # $_[0] = signal name or number (unused) @@ -663,7 +663,7 @@ sub write_pid ($) { } sub DESTROY { - unlink_pid_file_safe_ish($_[0]->{pid}, $_[0]->{pid_file}); + unlink_pid_file_safe_ish($_[0]->{pid}, ${$_[0]->{pid_file}}); } 1; diff --git a/t/httpd-unix.t b/t/httpd-unix.t index 425ecfff..939431f4 100644 --- a/t/httpd-unix.t +++ b/t/httpd-unix.t @@ -157,6 +157,7 @@ SKIP: { # drop the old parent kill('QUIT', $old_pid) or die "QUIT failed: $!"; delay_until(sub { !kill(0, $old_pid) }); + ok(!-f "$pid_file.oldbin", '.oldbin PID file gone'); # drop the new child check_sock($unix);