mirror of
https://github.com/samba-team/samba.git
synced 2025-08-24 21:49:29 +03:00
Eventscript functions - optimise is_ctdb_managed_service().
This function generates a lot of trace when running under "set -x". This is due to the backward compatibility code. This adds 3 optimisations: 1. Before invoking the backward compatiblity code, is_ctdb_managed_service() returns early if the service is listed in $CTDB_MANAGED_SERVICES. 2. ctdb_compat_managed_service() actually now updates $CTDB_MANAGED_SERVICES instead of temporary variable $t. This means that a subsequent call to is_ctdb_managed_service() will short circuit due to optimisation (1). 3. ctdb_compat_managed_service() only adds a service to $CTDB_MANAGED_SERVICES if it is the service being checked by is_ctdb_managed_service(). This stops irrelevant services being added to $CTDB_MANAGED_SERVICES multiple times by multiple calls to is_ctdb_managed_service(). Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit 758f4667c60089e09a0439c1eb74f5e426ca5e2e)
This commit is contained in:
@ -669,8 +669,8 @@ ctdb_service_reconfigure ()
|
||||
|
||||
ctdb_compat_managed_service ()
|
||||
{
|
||||
if [ "$1" = "yes" ] ; then
|
||||
t="$t $2 "
|
||||
if [ "$1" = "yes" -a "$2" = "$_service_name" ] ; then
|
||||
CTDB_MANAGED_SERVICES="$CTDB_MANAGED_SERVICES $2"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -678,8 +678,17 @@ is_ctdb_managed_service ()
|
||||
{
|
||||
_service_name="${1:-${service_name}}"
|
||||
|
||||
# $t is used just for readability and to allow better accurate
|
||||
# matching via leading/trailing spaces
|
||||
t=" $CTDB_MANAGED_SERVICES "
|
||||
|
||||
# Return 0 if "<space>$_service_name<space>" appears in $t
|
||||
if [ "${t#* ${_service_name} }" != "${t}" ] ; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
# If above didn't match then update $CTDB_MANAGED_SERVICES for
|
||||
# backward compatibility and try again.
|
||||
ctdb_compat_managed_service "$CTDB_MANAGES_VSFTPD" "vsftpd"
|
||||
ctdb_compat_managed_service "$CTDB_MANAGES_SAMBA" "samba"
|
||||
ctdb_compat_managed_service "$CTDB_MANAGES_SCP" "scp"
|
||||
@ -690,7 +699,9 @@ is_ctdb_managed_service ()
|
||||
ctdb_compat_managed_service "$CTDB_MANAGES_NFS" "nfs"
|
||||
ctdb_compat_managed_service "$CTDB_MANAGES_NFS" "nfs-ganesha-gpfs"
|
||||
|
||||
# Returns 0 if "<space>$_service_name<space>" appears in $t
|
||||
t=" $CTDB_MANAGED_SERVICES "
|
||||
|
||||
# Return 0 if "<space>$_service_name<space>" appears in $t
|
||||
[ "${t#* ${_service_name} }" != "${t}" ]
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user