From: Martin Schwenke Date: Tue, 6 Feb 2018 02:51:23 +0000 (+1100) Subject: ctdb-scripts: Move failure counters to the service state directory X-Git-Tag: talloc-2.1.12~225 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bcadab714987b375b3ab4379bef23514e12ad24f;p=thirdparty%2Fsamba.git ctdb-scripts: Move failure counters to the service state directory Scripts that use these counters must call ctdb_setup_state_dir(). Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/config/events.d/01.reclock b/ctdb/config/events.d/01.reclock index cceb672c8e0..44e49f44507 100755 --- a/ctdb/config/events.d/01.reclock +++ b/ctdb/config/events.d/01.reclock @@ -8,6 +8,8 @@ loadconfig +ctdb_setup_state_dir "service" "reclock" + # If CTDB_RECOVERY_LOCK specifies a helper then exit because this # script can't do anything useful. case "$CTDB_RECOVERY_LOCK" in diff --git a/ctdb/config/events.d/41.httpd b/ctdb/config/events.d/41.httpd index 3e45768fd92..adba3972134 100755 --- a/ctdb/config/events.d/41.httpd +++ b/ctdb/config/events.d/41.httpd @@ -23,6 +23,8 @@ suse|debian|*) ;; esac +ctdb_setup_state_dir "service" "$service_name" + # RHEL5 sometimes use a SIGKILL to terminate httpd, which then leaks # semaphores. This is a hack to clean them up. cleanup_httpd_semaphore_leak() { diff --git a/ctdb/config/functions b/ctdb/config/functions index 5070796a269..b3b348aebe2 100755 --- a/ctdb/config/functions +++ b/ctdb/config/functions @@ -697,10 +697,21 @@ interface_monitor () ######################################################## # Simple counters -_ctdb_counter_common () { - _service_name="${1:-${service_name:-${script_name}}}" - _counter_file="${CTDB_SCRIPT_VARDIR}/failcount/${_service_name}" - mkdir -p "${_counter_file%/*}" # dirname +_ctdb_counter_common () +{ + [ $# -le 1 ] || die "usage: _ctdb_counter_common [name]" + + if [ $# -eq 1 ] ; then + _counter_name="${1}.failcount" + else + _counter_name="failcount" + fi + + if [ -z "$script_state_dir" ] ; then + die "ctdb_counter_* functions need ctdb_setup_state_dir()" + fi + + _counter_file="${script_state_dir}/${_counter_name}" } # Some code passes an argument # shellcheck disable=SC2120