ctdb-scripts: Remove PID file only if it existed
authorMartin Schwenke <martin@meltin.net>
Wed, 21 Oct 2015 03:12:40 +0000 (14:12 +1100)
committerAmitay Isaacs <amitay@samba.org>
Wed, 28 Oct 2015 05:40:27 +0000 (06:40 +0100)
If 2 attempts are made to start CTDB in quick succession then it is
possible for the 2nd attempt to remove a newly created PID file from
the 1st.

If the PID file existed then the PID/SID from ctdbd_is_running() will
be passed to kill_ctdbd().  If the PID file did not exist then there
is no point removing it.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/config/ctdbd_wrapper

index 66d88c9559cd83235ec1f3c38d4730a624fe0b51..0218393ff639d7799d6f7c8c29f122089d6a844c 100755 (executable)
@@ -148,8 +148,8 @@ kill_ctdbd ()
 
     if [ -n "$_session" ] ; then
        pkill -9 -s "$_session" 2>/dev/null
+       rm -f "$pidfile"
     fi
-    rm -f "$pidfile"
 }
 
 ############################################################