From f05c6d32cce334d29e373f1e74f0b52cab14409d Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Fri, 23 Oct 2015 14:04:04 +1100 Subject: [PATCH] ctdb-scripts: Improve CTDB wrapper shutdown code This will make it easier to run things after CTDB is stopped. Signed-off-by: Martin Schwenke Reviewed-by: Michael Adam --- ctdb/config/ctdbd_wrapper | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/ctdb/config/ctdbd_wrapper b/ctdb/config/ctdbd_wrapper index c98c1906eb9..2ff8183b6fa 100755 --- a/ctdb/config/ctdbd_wrapper +++ b/ctdb/config/ctdbd_wrapper @@ -249,23 +249,29 @@ stop() # Wait for remaining CTDB processes to exit... _timeout=${CTDB_SHUTDOWN_TIMEOUT:-30} _count=0 + _terminated=false while [ $_count -lt $_timeout ] ; do - pkill -0 -s "$_session" 2>/dev/null || return 0 + if ! pkill -0 -s "$_session" 2>/dev/null ; then + _terminated=true + break + fi _count=$(($_count + 1)) sleep 1 done - echo "Timed out waiting for CTDB to shutdown. Killing CTDB processes." - kill_ctdbd "$_session" - drop_all_public_ips >/dev/null 2>&1 + if ! $_terminated ; then + echo "Timed out waiting for CTDB to shutdown. Killing CTDB processes." + kill_ctdbd "$_session" + drop_all_public_ips >/dev/null 2>&1 - sleep 1 + sleep 1 - if pkill -0 -s "$_session" ; then - # If SIGKILL didn't work then things are bad... - echo "Failed to kill all CTDB processes. Giving up." - return 1 + if pkill -0 -s "$_session" ; then + # If SIGKILL didn't work then things are bad... + echo "Failed to kill all CTDB processes. Giving up." + return 1 + fi fi return 0 -- 2.34.1