summaryrefslogtreecommitdiffstats
path: root/ctdb/server/eventscript.c
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2013-02-05 15:49:52 +1100
committerAmitay Isaacs <amitay@gmail.com>2013-02-05 16:05:13 +1100
commitbc5f0a2b651109d1f271d167f8d233763ec4f4a9 (patch)
tree725002fc20bba86a20e2fbba8333060c0fc7c77f /ctdb/server/eventscript.c
parentf2428cadd8e724ef306c4cc08f191585aa07e9dc (diff)
downloadsamba-bc5f0a2b651109d1f271d167f8d233763ec4f4a9.tar.gz
samba-bc5f0a2b651109d1f271d167f8d233763ec4f4a9.tar.xz
samba-bc5f0a2b651109d1f271d167f8d233763ec4f4a9.zip
ctdbd: Remove command-line option --debug-hung-script
Use an environment variable instead. This just means that the initscript exports CTDB_DEBUG_HUNG_SCRIPT and the code checks for the environment variable. The justification for this simplification is that more debug options will be arriving soon and we want to handle them consistently without needing to add a command-line option for each. So, the convention will be to use an environment variable for each debug option. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit 0581f9a84e58764d194f4e04064c2c5b393c348b)
Diffstat (limited to 'ctdb/server/eventscript.c')
-rw-r--r--ctdb/server/eventscript.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/ctdb/server/eventscript.c b/ctdb/server/eventscript.c
index 20f16fa156c..24183a41e4c 100644
--- a/ctdb/server/eventscript.c
+++ b/ctdb/server/eventscript.c
@@ -503,21 +503,12 @@ static void ctdb_event_script_handler(struct event_context *ev, struct fd_event
}
}
-/*
- setup the script to debug hung eventscripts
-*/
-int ctdb_set_debug_hung_script(struct ctdb_context *ctdb, const char *script)
-{
- ctdb->debug_hung_script = talloc_strdup(ctdb, script);
- CTDB_NO_MEMORY(ctdb, ctdb->debug_hung_script);
- return 0;
-}
-
static void ctdb_run_debug_hung_script(struct ctdb_context *ctdb, struct ctdb_event_script_state *state)
{
struct ctdb_script_wire *current = get_current_script(state);
char *cmd;
pid_t pid;
+ const char * debug_hung_script = ETCDIR "/ctdb/debug-hung-script.sh";
cmd = child_command_string(ctdb, state,
state->from_user, current->name,
@@ -543,18 +534,22 @@ static void ctdb_run_debug_hung_script(struct ctdb_context *ctdb, struct ctdb_ev
struct stat st;
char buf[200];
- if (stat(ctdb->debug_hung_script, &st) != 0) {
- DEBUG(DEBUG_ERR,("Failed to stat the script to debug hung eventscript. Is it not installed correctly? (script:%s)\n", ctdb->debug_hung_script));
+ if (getenv("CTDB_DEBUG_HUNG_SCRIPT") != NULL) {
+ debug_hung_script = getenv("CTDB_DEBUG_HUNG_SCRIPT");
+ }
+
+ if (stat(debug_hung_script, &st) != 0) {
+ DEBUG(DEBUG_ERR,("Failed to stat the script to debug hung eventscript. Is it not installed correctly? (script:%s)\n", debug_hung_script));
ctdb_kill(state->ctdb, state->child, SIGTERM);
_exit(0);
}
if (!(st.st_mode & S_IXUSR)) {
- DEBUG(DEBUG_DEBUG,("Debug script %s is not executable.\n", ctdb->debug_hung_script));
+ DEBUG(DEBUG_DEBUG,("Debug script %s is not executable.\n", debug_hung_script));
ctdb_kill(state->ctdb, state->child, SIGTERM);
_exit(0);
}
- sprintf(buf, "%s %d", ctdb->debug_hung_script, state->child);
+ sprintf(buf, "%s %d", debug_hung_script, state->child);
system(buf);
/* Now we can kill the child */