From a9c8b9e89b9bc1affc11db9c84b0a2bc079331d3 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 8 Apr 2010 15:09:08 +0930 Subject: eventscript: wait for debugging dump before killing timedout script Fairly simple: prevent the destructor from killing the script, and do it explicitly from the debugging child. We can remove the extra "already dead" test, since this will be detected in the destructor anyway. Signed-off-by: Rusty Russell (This used to be ctdb commit f8aa83788e3cc10ab7655a90d7b7b17ddbe48685) --- ctdb/server/eventscript.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'ctdb/server/eventscript.c') diff --git a/ctdb/server/eventscript.c b/ctdb/server/eventscript.c index 41da296031..2691d8f6ec 100644 --- a/ctdb/server/eventscript.c +++ b/ctdb/server/eventscript.c @@ -522,6 +522,8 @@ static void debug_timeout(struct ctdb_event_script_state *state) if (pid == 0) { ctdb_reduce_priority(state->ctdb); system(buf); + /* Now we can kill the child */ + kill(state->child, SIGTERM); exit(0); } if (pid == -1) { @@ -529,6 +531,8 @@ static void debug_timeout(struct ctdb_event_script_state *state) strerror(errno))); } else { DEBUG(DEBUG_ERR,("Logged timedout eventscript : %s\n", buf)); + /* Don't kill child until timeout done. */ + state->child = 0; } } @@ -560,11 +564,6 @@ static void ctdb_event_script_timeout(struct event_context *ev, struct timed_eve debug_timeout(state); } - if (kill(state->child, 0) != 0) { - DEBUG(DEBUG_ERR,("Event script child process already dead, errno %s(%d)\n", strerror(errno), errno)); - state->child = 0; - } - talloc_free(state); } -- cgit