squid: Speed up the stop process.
authorStefan Schantl <stefan.schantl@ipfire.org>
Tue, 11 Jun 2013 14:44:51 +0000 (16:44 +0200)
committerStefan Schantl <stefan.schantl@ipfire.org>
Tue, 11 Jun 2013 15:53:20 +0000 (17:53 +0200)
The squid proxy server has been blocked by unresponsive redirectors and it took ages to kill it in the past.

To speed up the shutdown process, we will stop all redirector services at the same time. If the squid service
is still running we will wait up to 30 seconds before a TERM and finaly a KILL signal will be sent.

Fixes #10368.

src/initscripts/init.d/squid

index 1a1425d..08a3029 100644 (file)
@@ -86,10 +86,31 @@ case "$1" in
                        boot_mesg "Stopping Squid Proxy Server..."
                        squid -k shutdown >/dev/null 2>&1
                        evaluate_retval
-                       killproc /usr/bin/squidGuard >/dev/null
-                       killproc /usr/sbin/updxlrator >/dev/null
-                       killproc /usr/bin/squidclamav >/dev/null
+
+                       # Stop squidGuard, updxlrator, squidclamav
+                       # and redirect_wrappers.                        
+                       killproc /usr/bin/squidGuard >/dev/null &
+                       killproc /usr/sbin/updxlrator >/dev/null &
+                       killproc /usr/bin/squidclamav >/dev/null &
+                       killproc /usr/sbin/redirect_wrapper >/dev/null &
+
+                       # Wait until all redirectors have been stopped.
+                       wait
+
+                       # If squid is still running, wait up to 30 seconds
+                       # before we go on to kill it.
+                       counter=30
+
+                       while [ ${counter} -gt 0 ]; do
+                               statusproc /usr/sbin/squid >/dev/null && break;
+                               sleep 1
+                               counter=$(( ${counter} - 1))
+                       done
+
+                       # Kill squid service, if still running.
                        killproc /usr/sbin/squid >/dev/null
+
+                       # Trash remain pid file from squid.
                        rm -rf /var/run/squid.pid       
                fi
                ;;