[Pkg-net-snmp-devel] Bug#640456: snmpd: init script may try to restart daemon before it terminates
Saj Goonatilleke
saj.goonatilleke at anchor.net.au
Sun Sep 4 23:34:35 UTC 2011
Package: snmpd
Version: 5.4.3~dfsg-2
Problem:
`invoke-rc.d snmpd restart' may sometimes fail if the snmpd daemon
does not terminate by the time the init script's 2-second sleep
expires:
invoke-rc.d: initscript snmpd, action "restart" failed.
The chance of failure is significant enough at sites where
restarting snmpd across several hundred servers every day can
reliably trip it over.
Expected behaviour:
The init script should wait for the daemon to terminate before
trying to start it back up again. Adding --retry to
start-stop-daemon solved the problem for me.
Patch:
---------------------------------- 8< ----------------------------------
--- a/debian/snmpd.init
+++ b/debian/snmpd.init
@@ -55,18 +55,16 @@
;;
stop)
echo -n "Stopping network management services:"
- start-stop-daemon --quiet --stop --oknodo --exec /usr/sbin/snmpd
+ start-stop-daemon --quiet --stop --oknodo --retry 2 --exec /usr/sbin/snmpd
echo -n " snmpd"
- start-stop-daemon --quiet --stop --oknodo --exec /usr/sbin/snmptrapd
+ start-stop-daemon --quiet --stop --oknodo --retry 2 --exec /usr/sbin/snmptrapd
echo -n " snmptrapd"
echo "."
;;
restart)
echo -n "Restarting network management services:"
- start-stop-daemon --quiet --stop --oknodo --exec /usr/sbin/snmpd
- start-stop-daemon --quiet --stop --oknodo --exec /usr/sbin/snmptrapd
- # Allow the daemons time to exit completely.
- sleep 2
+ start-stop-daemon --quiet --stop --oknodo --retry 2 --exec /usr/sbin/snmpd
+ start-stop-daemon --quiet --stop --oknodo --retry 2 --exec /usr/sbin/snmptrapd
if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then
start-stop-daemon --quiet --start --exec /usr/sbin/snmpd -- $SNMPDOPTS
echo -n " snmpd"
---------------------------------- >8 ----------------------------------
Thanks!
More information about the Pkg-net-snmp-devel
mailing list