Wait for Apache to really stop
authorJamie Cameron <jcameron@webmin.com>
Mon, 13 Oct 2008 21:55:42 +0000 (21:55 +0000)
committerJamie Cameron <jcameron@webmin.com>
Mon, 13 Oct 2008 21:55:42 +0000 (21:55 +0000)
apache/CHANGELOG
apache/apache-lib.pl
apache/save_mods.cgi

index 1660390..798f437 100644 (file)
@@ -41,3 +41,4 @@ Moved the SSL password option to the global settings level, to correspond with t
 Added support for the funny ${APACHE_RUN_USER} and ${APACHE_PID_FILE} variables seen in apache2.conf on Ubuntu 8.04.
 ---- Changes since 1.430 ----
 When a virtual host's base directory is changed, all <directory> blocks under it are updated too.
+When stopping and re-starting Apache, give it time to fully stop before continuing.
index 13966de..3aeddbb 100644 (file)
@@ -1434,6 +1434,7 @@ if ($config{'apply_cmd'} eq 'restart') {
        # Call stop and start functions
        local $err = &stop_apache();
        return $err if ($err);
+       local $stopped = &wait_for_apache_stop();
        local $err = &start_apache();
        return $err if ($err);
        }
@@ -1599,6 +1600,18 @@ else {
        }
 }
 
+# wait_for_apache_stop([secs])
+# Wait 30 (by default) seconds for Apache to stop. Returns 1 if OK, 0 if not
+sub wait_for_apache_stop
+{
+local $secs = $_[0] || 30;
+for(my $i=0; $i<$secs; $i++) {
+       return 1 if (!&is_apache_running());
+       sleep(1);
+       }
+return 0;
+}
+
 # configurable_modules()
 # Returns a list of Apaches that are compiled in or dynamically loaded, and
 # supported by Webmin.
index 18c02ad..a219d9f 100644 (file)
@@ -29,6 +29,7 @@ unlink($site_file);
 if ($changed && &is_apache_running()) {
        $err = &stop_apache();
        &error($err) if ($err);
+       &wait_for_apache_stop();
        $err = &start_apache();
        &error($err) if ($err);
        }