diff --git a/source/web/startstop.c b/source/web/startstop.c index c6babff9543..93e8650c2bc 100644 --- a/source/web/startstop.c +++ b/source/web/startstop.c @@ -22,8 +22,6 @@ #include "../web/swat_proto.h" #include "dynconfig.h" -/** Need to wait for daemons to startup */ -#define SLEEP_TIME 3 /** Startup smbd from web interface. */ void start_smbd(void) @@ -33,7 +31,6 @@ void start_smbd(void) if (geteuid() != 0) return; if (fork()) { - sleep(SLEEP_TIME); return; } @@ -54,7 +51,6 @@ void start_nmbd(void) if (geteuid() != 0) return; if (fork()) { - sleep(SLEEP_TIME); return; } @@ -75,7 +71,6 @@ void start_winbindd(void) if (geteuid() != 0) return; if (fork()) { - sleep(SLEEP_TIME); return; } @@ -133,5 +128,4 @@ void kill_pid(pid_t pid) if (pid <= 0) return; kill(pid, SIGTERM); - sleep(SLEEP_TIME); } diff --git a/source/web/statuspage.c b/source/web/statuspage.c index ddbe658a6cb..44461232b81 100644 --- a/source/web/statuspage.c +++ b/source/web/statuspage.c @@ -23,6 +23,9 @@ #define PIDMAP struct PidMap +/* how long to wait for start/stops to take effect */ +#define SLEEP_TIME 3 + PIDMAP { PIDMAP *next, *prev; pid_t pid; @@ -158,6 +161,7 @@ static int traverse_fn1(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, void* st slprintf(buf,sizeof(buf)-1,"kill_%d", (int)crec.pid); if (cgi_variable(buf)) { kill_pid(crec.pid); + sleep(SLEEP_TIME); } } return 0; @@ -221,48 +225,62 @@ void status_page(void) int refresh_interval=30; TDB_CONTEXT *tdb; int nr_running=0; + BOOL waitup = False; smbd_pid = pidfile_pid("smbd"); if (cgi_variable("smbd_restart") || cgi_variable("all_restart")) { stop_smbd(); start_smbd(); + waitup=True; } if (cgi_variable("smbd_start") || cgi_variable("all_start")) { start_smbd(); + waitup=True; } if (cgi_variable("smbd_stop") || cgi_variable("all_stop")) { stop_smbd(); + waitup=True; } if (cgi_variable("nmbd_restart") || cgi_variable("all_restart")) { stop_nmbd(); start_nmbd(); + waitup=True; } if (cgi_variable("nmbd_start") || cgi_variable("all_start")) { start_nmbd(); + waitup=True; } if (cgi_variable("nmbd_stop")|| cgi_variable("all_stop")) { stop_nmbd(); + waitup=True; } #ifdef WITH_WINBIND if (cgi_variable("winbindd_restart") || cgi_variable("all_restart")) { stop_winbindd(); start_winbindd(); + waitup=True; } if (cgi_variable("winbindd_start") || cgi_variable("all_start")) { start_winbindd(); + waitup=True; } if (cgi_variable("winbindd_stop") || cgi_variable("all_stop")) { stop_winbindd(); + waitup=True; } #endif + /* wait for daemons to start/stop */ + if (waitup) + sleep(SLEEP_TIME); + if (cgi_variable("autorefresh")) { autorefresh = 1; } else if (cgi_variable("norefresh")) { @@ -333,20 +351,7 @@ void status_page(void) } else { d_printf("