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 3/2 (squash)] t/httpd-unix: fix race in SIGUSR2 test
Date: Tue, 24 Mar 2020 07:24:40 +0000	[thread overview]
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	other threads:[~2020-03-24  7:24 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   ` 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: 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=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
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).