Eventscript functions - optimise is_ctdb_managed_service().
authorMartin Schwenke <martin@meltin.net>
Thu, 18 Nov 2010 05:19:45 +0000 (16:19 +1100)
committerMartin Schwenke <martin@meltin.net>
Thu, 11 Aug 2011 00:46:20 +0000 (10:46 +1000)
commit758f4667c60089e09a0439c1eb74f5e426ca5e2e
tree7382d8ab09c011783bddc3aac0882e0d1ed153ed
parent538902fbc1e74134a03987b36b3733ad641f8971
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>
config/functions