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 F1EED1F45D; Tue, 24 Mar 2020 07:24:40 +0000 (UTC) Date: Tue, 24 Mar 2020 07:24:40 +0000 From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 3/2 (squash)] t/httpd-unix: fix race in SIGUSR2 test Message-ID: <20200324072440.GA59801@dcvr> References: <20200322085849.14360-1-e@yhbt.net> <20200322085849.14360-2-e@yhbt.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200322085849.14360-2-e@yhbt.net> List-Id: 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 {