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 <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
_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