From: Martin Schwenke Date: Fri, 17 Apr 2015 10:44:15 +0000 (+1000) Subject: ctdb-scripts: New function ctdb_get_pnn() does cached retrieval of PNN X-Git-Tag: tdb-1.3.5~18 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=579dda6858f547d360073cd67235e49ab03b355e;p=thirdparty%2Fsamba.git ctdb-scripts: New function ctdb_get_pnn() does cached retrieval of PNN This avoids the expense of establishing a client connection to the daemon just to get the PNN of the current node. Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/config/functions b/ctdb/config/functions index 1b2384ec088..da69ef44e8a 100755 --- a/ctdb/config/functions +++ b/ctdb/config/functions @@ -198,6 +198,20 @@ nice_service() _service "$@" } +###################################################### +# Cached retrieval of PNN from local node. This never changes so why +# open a client connection to the server each time this is needed? +# This sets $pnn - this avoid an unnecessary subprocess. +ctdb_get_pnn () +{ + _pnn_file="$CTDB_VARDIR/state/my-pnn" + if [ ! -f "$_pnn_file" ] ; then + ctdb pnn | sed -e 's@.*:@@' >"$_pnn_file" + fi + + read pnn <"$_pnn_file" +} + ###################################################### # wrapper around /proc/ settings to allow them to be hooked # for testing