2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 05:57:52 +00:00

Fix waiting for lock file removal upon exit

Commit c787a539d2a931ba9023677c1c269ed191455512 fixed a certain class of
intermittent system test failures caused by named instances unable to
restart.  The root cause was bin/tests/system/stop.pl returning without
waiting for a named instance to remove its lock file.

Later on, it turned out that the above change causes other issues on
Windows due to the way named handles signals on that platform.  Commit
761ba4514f7eceab8019d71dc9cabd269d274597 intended to address those
issues by making the server_lock_file() subroutine in
bin/tests/system/stop.pl return an empty value on Windows, in order to
prevent the script for waiting for lock file cleanup on that platform.
Note, however, that Windows detection in that subroutine is limited to
checking whether the CYGWIN environment variable is set.

While that environment variable was not set on Unix-like systems before
commit 761ba4514f7eceab8019d71dc9cabd269d274597, another commit
(a33237f070c95480f581d85b0169f41ce5a12017, merged a few weeks later)
changed that by setting the CYGWIN environment variable to an empty
value on Unix-like systems.  This made the defined($ENV{'CYGWIN'}) check
in server_lock_file() return true, inadvertently preventing
bin/tests/system/stop.pl from waiting for lock file removal before
exiting on Unix-like systems and therefore reintroducing the original
issue.

Fix by making server_lock_file() only return an empty value when the
CYGWIN environment variable is set to a non-empty value (which is what
bin/tests/system/conf.sh.win32 does).  Adjust a similar check in the
pid_file_exists() subroutine in the same way for consistency.
This commit is contained in:
Michał Kępień 2022-01-26 15:18:43 +01:00
parent fb87022115
commit a938db2170

View File

@ -134,7 +134,7 @@ exit($errors);
sub server_lock_file {
my ( $server ) = @_;
return if (defined($ENV{'CYGWIN'}));
return if (defined($ENV{'CYGWIN'}) && $ENV{'CYGWIN'});
return $testdir . "/" . $server . "/named.lock" if ($server =~ /^ns/);
return if ($server =~ /^ans/);
@ -255,7 +255,7 @@ sub pid_file_exists {
if (send_signal(0, $pid) == 0) {
# XXX: on windows this is likely to result in a
# false positive, so don't bother reporting the error.
if (!defined($ENV{'CYGWIN'})) {
if (!defined($ENV{'CYGWIN'}) || !$ENV{'CYGWIN'}) {
print "I:$test:$server crashed on shutdown\n";
$errors = 1;
}