]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Make stop.pl wait for lock file cleanup
authorMichał Kępień <michal@isc.org>
Tue, 19 Mar 2019 09:26:36 +0000 (10:26 +0100)
committerMichał Kępień <michal@isc.org>
Tue, 19 Mar 2019 09:26:36 +0000 (10:26 +0100)
bin/tests/system/stop.pl only waits for the PID file to be cleaned up
while named cleans up the lock file after the PID file.  Thus, the
aforementioned script may consider a named instance to be fully shut
down when in fact it is not.

Fix by also checking whether the lock file exists when determining a
given instance's shutdown status.  This change assumes that if a named
instance uses a lock file, it is called "named.lock".

Also rename clean_pid_file() to pid_file_exists(), so that it is called
more appropriately (it does not clean up the PID file itself, it only
returns the server's identifier if its PID file is not yet cleaned up).

bin/tests/system/stop.pl

index 0a1358a275bc8b853c0d168eeda503d5da339a68..1045ee374fb6cae20ec96913eff85b4bffe6c567 100644 (file)
@@ -127,9 +127,19 @@ exit($errors);
 
 # Subroutines
 
+# Return the full path to a given server's lock file.
+sub server_lock_file {
+       my ( $server ) = @_;
+
+       return $testdir . "/" . $server . "/named.lock" if ($server =~ /^ns/);
+       return if ($server =~ /^ans/);
+
+       die "Unknown server type $server\n";
+}
+
 # Return the full path to a given server's PID file.
 sub server_pid_file {
-       my($server) = @_;
+       my ( $server ) = @_;
 
        return $testdir . "/" . $server . "/named.pid" if ($server =~ /^ns/);
        return $testdir . "/" . $server . "/ans.pid" if ($server =~ /^ans/);
@@ -228,7 +238,7 @@ sub stop_signal {
        return;
 }
 
-sub clean_pid_file {
+sub pid_file_exists {
        my ( $server ) = @_;
 
        my $pid_file = server_pid_file($server);
@@ -250,6 +260,15 @@ sub clean_pid_file {
        return $server;
 }
 
+sub lock_file_exists {
+       my ( $server ) = @_;
+       my $lock_file = server_lock_file($server);
+
+       return unless defined($lock_file) && -f $lock_file;
+
+       return $server;
+}
+
 sub wait_for_servers {
        my ( $timeout, @servers ) = @_;
 
@@ -257,7 +276,7 @@ sub wait_for_servers {
                sleep 1 if (@servers > 0);
                @servers =
                        grep { defined($_) }
-                       map  { clean_pid_file($_) } @servers;
+                       map  { pid_file_exists($_) || lock_file_exists($_) } @servers;
                $timeout--;
        }