user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@yhbt.net>
To: meta@public-inbox.org
Subject: [PATCH 2/2] daemon: unlink .oldbin PID file correctly
Date: Sun, 22 Mar 2020 08:58:49 +0000	[thread overview]
Message-ID: <20200322085849.14360-3-e@yhbt.net> (raw)
In-Reply-To: <20200322085849.14360-1-e@yhbt.net>

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);

      parent reply	other threads:[~2020-03-22  8:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-22  8:58 [PATCH 0/2] daemon: SIGUSR2 fixes Eric Wong
2020-03-22  8:58 ` [PATCH 1/2] daemon: fix SIGUSR2 upgrade with -W0 (no workers) Eric Wong
2020-03-24  7:24   ` [PATCH 3/2 (squash)] t/httpd-unix: fix race in SIGUSR2 test Eric Wong
2020-03-22  8:58 ` Eric Wong [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200322085849.14360-3-e@yhbt.net \
    --to=e@yhbt.net \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).