eventscript: wait for debugging dump before killing timedout script
authorRusty Russell <rusty@rustcorp.com.au>
Thu, 8 Apr 2010 05:39:08 +0000 (15:09 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Thu, 8 Apr 2010 05:39:08 +0000 (15:09 +0930)
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 <rusty@rustcorp.com.au>
server/eventscript.c

index 41da296031b81e6cce0195c0162ae3d8772dc84e..2691d8f6ec8cdf0685fa58f249eaa17aa508e1b6 100644 (file)
@@ -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);
 }