#521300 squid3: use s-s-d --retry functionality rather than shell reimplementttion

Package:
squid3
Source:
squid
Submitter:
Justin Pryzby
Date:
2025-07-28 19:45:06 UTC
Severity:
wishlist
Tags:
#521300#5
Date:
2009-03-26 15:07:05 UTC
From:
To:
See comments in the dpkg source, it does the same thing internally
with greater efficiency.  On our proxy squid restarts in 5 seconds now
instead of 25.
--- /etc/init.d/squid3
+++ /tmp/tmp.U14159/squid3	2009-03-26 08:01:43.000000000 -0700
@@ -77,32 +77,8 @@
 }

 stop () {
-	PID=`cat $PIDFILE 2>/dev/null`
-	start-stop-daemon --stop --quiet --pidfile $PIDFILE --exec $DAEMON
-	#
-	#	Now we have to wait until squid has _really_ stopped.
-	#
-	sleep 2
-	if test -n "$PID" && kill -0 $PID 2>/dev/null
-	then
-		log_action_begin_msg " Waiting"
-		cnt=0
-		while kill -0 $PID 2>/dev/null
-		do
-			cnt=`expr $cnt + 1`
-			if [ $cnt -gt 24 ]
-			then
-				log_action_end_msg 1
-				return 1
-			fi
-			sleep 5
-			log_action_cont_msg ""
-		done
-		log_action_end_msg 0
-		return 0
-	else
-		return 0
-	fi
+	start-stop-daemon --stop --quiet --retry 5 --pidfile "$PIDFILE" --exec $DAEMON
+	return 0
 }

 case "$1" in

#521300#10
Date:
2009-07-06 10:39:05 UTC
From:
To:
Hi Justin,
actually your version of the init script does something different from
the original: after 5 seconds (timeout added to the --retry option) it
sends a KILL signal to squid, which stops all it is doing (ensuring
that the saved state of the cache is coherent) and exits, leaving a
corrupted storage which will need to be rebuilt on the next startup.
This is why the original script waited for as long as two minutes for
squid to exit normally, and leaved it running if it needed more time.

So maybe you'll get some speed-ups on shutdown but will surely get
some slow-downs on startup, there is no clear win. :-)

The same behaviour as the original can be achieved adding the --retry
0/forever option, which tells s-s-d to wait forever for squid to exit,
but this will hang your terminal until squid does is job.

Maybe we should set a limit to something like 5 minutes with --retry
0/300/KILL/5 but I'm not sure that this solution is better than the
current code.

Regards,

L