From: Martin Schwenke Date: Tue, 1 Oct 2013 05:13:29 +0000 (+1000) Subject: ctdbd: Debug locks by default with override from enviroment variable X-Git-Tag: ctdb-2.5~31 X-Git-Url: http://git.samba.org/?p=ctdb.git;a=commitdiff_plain;h=c11803e3dcc905a45a08d743595e63f9ca445f0d ctdbd: Debug locks by default with override from enviroment variable Default is debug_locks.sh, relative to CTDB_BASE. Signed-off-by: Martin Schwenke --- diff --git a/server/ctdb_lock.c b/server/ctdb_lock.c index 1d27a444..fc437b0f 100644 --- a/server/ctdb_lock.c +++ b/server/ctdb_lock.c @@ -495,7 +495,7 @@ static void ctdb_lock_timeout_handler(struct tevent_context *ev, struct timeval current_time, void *private_data) { - const char *cmd = getenv("CTDB_DEBUG_LOCKS"); + static const char * debug_locks = NULL; struct lock_context *lock_ctx; struct ctdb_context *ctdb; pid_t pid; @@ -515,12 +515,24 @@ static void ctdb_lock_timeout_handler(struct tevent_context *ev, timeval_elapsed(&lock_ctx->start_time))); } - /* fire a child process to find the blocking process */ - if (cmd != NULL) { + /* Fire a child process to find the blocking process. */ + if (debug_locks == NULL) { + debug_locks = getenv("CTDB_DEBUG_LOCKS"); + if (debug_locks == NULL) { + debug_locks = talloc_asprintf(ctdb, + "%s/debug_locks.sh", + getenv("CTDB_BASE")); + } + } + if (debug_locks != NULL) { pid = fork(); if (pid == 0) { - execl(cmd, cmd, NULL); + execl(debug_locks, debug_locks, NULL); } + } else { + DEBUG(DEBUG_WARNING, + (__location__ + " Unable to setup lock debugging - no memory?\n")); } /* reset the timeout timer */