diff --git a/mbtask/ping.c b/mbtask/ping.c index 116b9daa..54b5eb82 100644 --- a/mbtask/ping.c +++ b/mbtask/ping.c @@ -337,6 +337,7 @@ void *ping_thread(void) static int pingnr, pingresult[2]; static char pingaddress[41]; static time_t pingsend; + time_t now; Syslog('+', "Starting ping thread with pid %d", (int)getpid()); pingresult[1] = pingresult[2] = FALSE; @@ -371,7 +372,13 @@ void *ping_thread(void) if (icmp_errs++ < ICMP_MAX_ERRS) Syslog('?', "ping: to %s rc=%d", pingaddress, rc); pingresult[pingnr] = FALSE; - sleep(10); + now = time(NULL) + 10; + + while ((! T_Shutdown) && (time(NULL) < now)) { + sleep(1); + } + if (T_Shutdown) + break; } else { pingsend = time(NULL); @@ -398,10 +405,10 @@ void *ping_thread(void) if (rc > 5) Syslog('+', "Ping: slow reply after %d seconds", rc); pingresult[pingnr] = TRUE; - if (rc < 20) - sleep(20 - rc); - else + now = time(NULL) + 20 - rc; + while ((! T_Shutdown) && (time(NULL) < now)) { sleep(1); + } break; } else { if (rc != -6) { @@ -415,9 +422,15 @@ void *ping_thread(void) } else { if (icmp_errs++ < ICMP_MAX_ERRS) Syslog('?', "Ping address %d is invalid \"%s\"", pingnr, pingaddress); - sleep(10); + now = time(NULL) + 10; + while ((! T_Shutdown) && (time(NULL) < now)) { + sleep(1); + } } + if (T_Shutdown) + break; + /* * Evaluate the result of the ping test */ diff --git a/script/init.Debian b/script/init.Debian index 64c488e3..e7508c15 100644 --- a/script/init.Debian +++ b/script/init.Debian @@ -50,6 +50,7 @@ case "$1" in su mbse -c '$MBSE_ROOT/bin/mbstat close wait -quiet' >/dev/null fi kill `pidof mbtask` + sleep 3 echo "$NAME done." ;; force-reload|restart) diff --git a/script/init.FreeBSD b/script/init.FreeBSD index 5b7eada9..3c810040 100644 --- a/script/init.FreeBSD +++ b/script/init.FreeBSD @@ -45,6 +45,8 @@ case "$1" in fi kill -15 `/usr/local/bin/pidof mbtask` echo -n " mbtask" + sleep 3 + echo -n " done" ;; *) echo "Usage: `basename $0` {start|stop}" >&2 diff --git a/script/init.Gentoo b/script/init.Gentoo index 65e891fb..e6821225 100644 --- a/script/init.Gentoo +++ b/script/init.Gentoo @@ -56,5 +56,6 @@ stop() { su mbse -c '$MBSE_ROOT/bin/mbstat close wait -quiet' >/dev/null fi kill `pidof mbtask` + sleep 3 eend $? "Stopping error." } diff --git a/script/init.RedHat b/script/init.RedHat index 78a83920..245f046d 100644 --- a/script/init.RedHat +++ b/script/init.RedHat @@ -89,6 +89,7 @@ case "$1" in echo -n "stop mbtask: " killproc mbtask -15 rm -f /var/lock/subsys/mbsed + sleep 3 echo "" # echo "done." ;; diff --git a/script/init.Slackware b/script/init.Slackware index 8d507d27..9bf5d5e9 100644 --- a/script/init.Slackware +++ b/script/init.Slackware @@ -48,6 +48,7 @@ case "$1" in fi echo -n " stopping mbtask " kill -15 `pidof $MBSE_ROOT/bin/mbtask` + sleep 3 echo "done." ;; status) diff --git a/script/init.SuSE b/script/init.SuSE index 7bde2d66..771da426 100644 --- a/script/init.SuSE +++ b/script/init.SuSE @@ -53,6 +53,7 @@ case "$1" in fi echo -n " stopping mbtask " killproc $MBSE_ROOT/bin/mbtask -15 + sleep 3 echo "done." ;; restart|reload)