diff options
author | Martin Schwenke <martin@meltin.net> | 2010-11-18 16:19:45 +1100 |
---|---|---|
committer | Martin Schwenke <martin@meltin.net> | 2011-08-11 10:46:20 +1000 |
commit | ea6a53e2b32f47b69e567a96da2f93c7505d018b (patch) | |
tree | f628d9c49274ec3bcb3f43c0f2a17ef076df29fa | |
parent | 6ec2cfc7da5835385364b198c83516551743bcaf (diff) | |
download | samba-ea6a53e2b32f47b69e567a96da2f93c7505d018b.tar.gz samba-ea6a53e2b32f47b69e567a96da2f93c7505d018b.tar.xz samba-ea6a53e2b32f47b69e567a96da2f93c7505d018b.zip |
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)
-rwxr-xr-x | ctdb/config/functions | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/ctdb/config/functions b/ctdb/config/functions index 32f11f0690..5c414585ca 100755 --- a/ctdb/config/functions +++ b/ctdb/config/functions @@ -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}" ] } |