On Mon, Dec 14, 2009 at 1:34 PM, Andrew Beekhof <[email protected]> wrote:
> And now with a functional patch.
> The important part was not to use status_args everywhere, but only for
> key calls to status()

Sigh, I also needed to give the included status() the same semantics
as the one in /etc/init.d/functions

>> On Mon, Dec 14, 2009 at 12:54 PM, Andrew Beekhof <[email protected]> wrote:
>>> If two stop actions are ever performed simultaneously, then neither will
>>> terminate.
>>> Without specifying a pidfile, the status() function from
>>> /etc/init.d/functions incorrectly thinks the other stop action is a real
>>> corosync process.
>>>
>>> Eg.
>>>
>>> [r...@pcmk-1 ~]# ps axf | grep corosync
>>> 16664 pts/0    S      0:00  |       \_ /bin/bash /etc/init.d/corosync stop
>>> 16669 pts/0    S+     0:00  |       \_ /bin/bash /etc/init.d/corosync stop
>>> 16849 pts/1    S+     0:00          \_ grep corosync
>>> [r...@pcmk-1 ~]# /etc/init.d/corosync status
>>> corosync (pid 16669 16664) is running...
>>> [r...@pcmk-1 ~]#
Index: init/generic.in
===================================================================
--- init/generic.in     (revision 2638)
+++ init/generic.in     (working copy)
@@ -23,6 +23,7 @@

 desc="Corosync Cluster Engine"
 prog="corosync"
+pid_fi...@localstatedir@/run/$prog.pid

 # set secure PATH
 PATH="/sbin:/bin:/usr/sbin:/usr/bin:@SBINDIR@"
@@ -39,6 +40,13 @@

 status()
 {
+       if [ "$1" = "-p" ]; then
+                shift 2
+        fi
+        if [ "$1" = "-l" ]; then
+                shift 2
+        fi
+
        pid=$(pidof $1 2>/dev/null)
        rtrn=$?
        if [ $rtrn -ne 0 ]; then
@@ -62,6 +70,8 @@
        [ -z "$LOCK_FILE" ] && LOCK_FILE="@LOCALSTATEDIR@/lock/$prog"
 fi

+status_args="-p $PID_FILE -l $LOCK_FILE"
+
 start()
 {
        echo -n "Starting $desc ($prog): "
@@ -72,7 +82,7 @@
        # required subdirectories for proper operations
        mkdir -p @LOCALSTATEDIR@/run

-       if status $prog > /dev/null 2>&1; then
+       if status $status_args $prog > /dev/null 2>&1; then
                success
        else
                $prog > /dev/null 2>&1
@@ -81,7 +91,7 @@
                sleep 2
                if status $prog > /dev/null 2>&1; then
                        touch $LOCK_FILE
-                       pidof $prog > @LOCALSTATEDIR@/run/$prog.pid
+                       pidof $prog > $PID_FILE
                        success
                else
                        failure
@@ -101,13 +111,13 @@
        echo

        echo -n "Waiting for $prog services to unload:"
-       while status $prog > /dev/null 2>&1; do
+       while status $status_args $prog > /dev/null 2>&1; do
                sleep 1
                echo -n "."
        done

        rm -f $LOCK_FILE
-       rm -f @LOCALSTATEDIR@/run/$prog.pid
+       rm -f $PID_FILE
        success
        echo
 }
@@ -133,7 +143,7 @@
        fi
 ;;
 status)
-       status $prog
+       status $status_args $prog
        rtrn=$?
 ;;
 stop)
_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais

Reply via email to