user/dev discussion of public-inbox itself
 help / color / Atom feed
From: Eric Wong <e@yhbt.net>
To: meta@public-inbox.org
Subject: [PATCH 3/2 (squash)] t/httpd-unix: fix race in SIGUSR2 test
Date: Tue, 24 Mar 2020 07:24:40 +0000
Message-ID: <20200324072440.GA59801@dcvr> (raw)
In-Reply-To: <20200322085849.14360-2-e@yhbt.net>

We need to stop workers in the old process, check the socket and
ensure $new_pid is ready to receive signals before killing it.
---
 t/httpd-unix.t | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/t/httpd-unix.t b/t/httpd-unix.t
index 939431f4..a0fe1e31 100644
--- a/t/httpd-unix.t
+++ b/t/httpd-unix.t
@@ -127,6 +127,10 @@ SKIP: {
 	is($?, 0, "daemonized process again");
 	check_sock($unix);
 	my $pid = $read_pid->($pid_file);
+
+	# stop worker to ensure check_sock below hits $new_pid
+	kill('TTOU', $pid) or die "TTOU failed: $!";
+
 	kill('USR2', $pid) or die "USR2 failed: $!";
 	delay_until(sub {
 		$pid != (eval { $read_pid->($pid_file) } // $pid)
@@ -136,6 +140,8 @@ SKIP: {
 	my $old_pid = $read_pid->("$pid_file.oldbin");
 	is($old_pid, $pid, '.oldbin pid file written');
 
+	check_sock($unix); # ensures $new_pid is ready to receive signals
+
 	# first, back out of the upgrade
 	kill('QUIT', $new_pid) or die "kill new PID failed: $!";
 	delay_until(sub {

  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   ` Eric Wong [this message]
2020-03-22  8:58 ` [PATCH 2/2] daemon: unlink .oldbin PID file correctly Eric Wong

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=20200324072440.GA59801@dcvr \
    --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 http://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