user/dev discussion of public-inbox itself
 help / color / 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
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 index

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: https://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

user/dev discussion of public-inbox itself

Archives are clonable:
	git clone --mirror https://public-inbox.org/meta
	git clone --mirror http://czquwvybam4bgbro.onion/meta
	git clone --mirror http://hjrcffqmbrq6wope.onion/meta
	git clone --mirror http://ou63pmih66umazou.onion/meta

Example config snippet for mirrors

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.mail.public-inbox.meta
	nntp://ou63pmih66umazou.onion/inbox.comp.mail.public-inbox.meta
	nntp://czquwvybam4bgbro.onion/inbox.comp.mail.public-inbox.meta
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.mail.public-inbox.meta
	nntp://news.gmane.io/gmane.mail.public-inbox.general

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git