]> 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 10:03:46 +0000 (11:03 +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", and that if an
lwresd instance uses a lock file, it is called "lwresd.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).

(cherry picked from commit c787a539d2a931ba9023677c1c269ed191455512)

bin/tests/system/stop.pl

index 1166315332605a6fa5ca3104d8318320d93ba159..4183981596200a8f7b2f2792b568ba62caa6aad3 100644 (file)
@@ -137,9 +137,20 @@ 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/);
+       return $testdir . "/" . $server . "/lwresd.lock" if ($server =~ /^lwresd/);
+
+       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/);
@@ -239,7 +250,7 @@ sub stop_signal {
        return;
 }
 
-sub clean_pid_file {
+sub pid_file_exists {
        my ( $server ) = @_;
 
        my $pid_file = server_pid_file($server);
@@ -261,6 +272,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 ) = @_;
 
@@ -268,7 +288,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--;
        }