Blame SOURCES/autofs-5.0.7-dont-wait-forever-to-restart.patch

ab3a3d
autofs-5.0.7 - dont wait forever to restart
ab3a3d
ab3a3d
From: Ian Kent <ikent@redhat.com>
ab3a3d
ab3a3d
When restarting autofs the daemon must be stopped before it is started
ab3a3d
again if it is to function properly. At the moment the init script waits
ab3a3d
forever which is not ok if the daemon won't exit for some reason.
ab3a3d
ab3a3d
So, if the daemon is still running after the stop, run stop() again, wait
ab3a3d
a bit longer and if it still hasn't stopped kill it with a SIGKILL to clear
ab3a3d
the way for the startup.
ab3a3d
---
ab3a3d
ab3a3d
 CHANGELOG             |    1 +
ab3a3d
 redhat/autofs.init.in |   13 ++++++++++---
ab3a3d
 2 files changed, 11 insertions(+), 3 deletions(-)
ab3a3d
ab3a3d
ab3a3d
diff --git a/CHANGELOG b/CHANGELOG
ab3a3d
index 6051723..93b9c26 100644
ab3a3d
--- a/CHANGELOG
ab3a3d
+++ b/CHANGELOG
ab3a3d
@@ -5,6 +5,7 @@
ab3a3d
 - fix ipv6 proximity calculation.
ab3a3d
 - fix parse buffer initialization.
ab3a3d
 - fix typo in automount(8).
ab3a3d
+- dont wait forever to restart.
ab3a3d
 
ab3a3d
 25/07/2012 autofs-5.0.7
ab3a3d
 =======================
ab3a3d
diff --git a/redhat/autofs.init.in b/redhat/autofs.init.in
ab3a3d
index ec6d5d6..cd5cb34 100644
ab3a3d
--- a/redhat/autofs.init.in
ab3a3d
+++ b/redhat/autofs.init.in
ab3a3d
@@ -129,9 +129,16 @@ function restart() {
ab3a3d
 	status autofs > /dev/null 2>&1
ab3a3d
 	if [ $? -eq 0 ]; then
ab3a3d
 		stop
ab3a3d
-		while [ -n "`pidof $prog`" ] ; do
ab3a3d
-			sleep 5
ab3a3d
-		done
ab3a3d
+		if [ -n "`pidof $prog`" ]; then
ab3a3d
+			# If we failed to stop, try at least one more time
ab3a3d
+			# after waiting a little while
ab3a3d
+			sleep 20
ab3a3d
+			stop
ab3a3d
+			auto_pid=`pidof $prog`
ab3a3d
+			if [ -n "$auto_pid" ]; then
ab3a3d
+				kill -9 $auto_pid
ab3a3d
+			fi
ab3a3d
+		fi
ab3a3d
 	fi
ab3a3d
 	start
ab3a3d
 }