summaryrefslogtreecommitdiffstats
path: root/ctdb/server/eventscript.c
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2009-12-08 12:24:56 +1030
committerRusty Russell <rusty@rustcorp.com.au>2009-12-08 12:24:56 +1030
commit6960fa96ebdb97ce585208fabdf5e2a8636fe824 (patch)
tree58a0d651257fbdbe28212a52051ca51afc1f31e8 /ctdb/server/eventscript.c
parente548a335bde6d7e229c68ae033e788db68bf76c7 (diff)
downloadsamba-6960fa96ebdb97ce585208fabdf5e2a8636fe824.tar.gz
samba-6960fa96ebdb97ce585208fabdf5e2a8636fe824.tar.xz
samba-6960fa96ebdb97ce585208fabdf5e2a8636fe824.zip
eventscript: cleanup finished to take state arg
We only need ctdb->current_monitor so we can kill it when we want to run something else; we don't need to use it here as we always know what script we are running. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (This used to be ctdb commit 4cf1b7c32bcf7e4b65aec1fa7ee1a4b162cac889)
Diffstat (limited to 'ctdb/server/eventscript.c')
-rw-r--r--ctdb/server/eventscript.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/ctdb/server/eventscript.c b/ctdb/server/eventscript.c
index 2dd894f03b..eb4bb22067 100644
--- a/ctdb/server/eventscript.c
+++ b/ctdb/server/eventscript.c
@@ -111,23 +111,18 @@ static void log_event_script_output(const char *str, uint16_t len, void *p)
}
/* called when all event script child processes are done */
-static int32_t ctdb_control_event_script_finished(struct ctdb_context *ctdb)
+static int32_t ctdb_control_event_script_finished(struct ctdb_context *ctdb,
+ struct ctdb_event_script_state *state)
{
DEBUG(DEBUG_INFO, ("event script finished called\n"));
- if (ctdb->current_monitor == NULL) {
- DEBUG(DEBUG_ERR,(__location__ " script_status is NULL when monitoring event finished\n"));
- return -1;
- }
-
talloc_free(ctdb->last_status);
- ctdb->last_status = talloc_steal(ctdb, ctdb->current_monitor->scripts);
+ ctdb->last_status = talloc_steal(ctdb, state->scripts);
/* if we didn't finish all the scripts, trim status array. */
- if (ctdb->current_monitor->current < ctdb->last_status->num_scripts) {
- ctdb->last_status->num_scripts
- = ctdb->current_monitor->current+1;
+ if (state->current < ctdb->last_status->num_scripts) {
+ ctdb->last_status->num_scripts = state->current+1;
}
- ctdb->current_monitor->scripts = NULL;
+ state->scripts = NULL;
return 0;
}
@@ -487,7 +482,7 @@ static void ctdb_event_script_handler(struct event_context *ev, struct fd_event
call_names[state->call], state->options, state->cb_status));
if (!state->from_user && state->call == CTDB_EVENT_MONITOR) {
- ctdb_control_event_script_finished(ctdb);
+ ctdb_control_event_script_finished(ctdb, state);
}
ctdb->event_script_timeouts = 0;
talloc_free(state);
@@ -502,7 +497,7 @@ static void ctdb_event_script_handler(struct event_context *ev, struct fd_event
state->cb_status = fork_child_for_script(ctdb, state);
if (state->cb_status != 0) {
if (!state->from_user && state->call == CTDB_EVENT_MONITOR) {
- ctdb_control_event_script_finished(ctdb);
+ ctdb_control_event_script_finished(ctdb, state);
}
/* This calls the callback. */
talloc_free(state);
@@ -528,7 +523,7 @@ static void ctdb_event_script_timeout(struct event_context *ev, struct timed_eve
if (state->call == CTDB_EVENT_MONITOR || state->call == CTDB_EVENT_STATUS) {
state->scripts->scripts[state->current].status = state->cb_status;
- ctdb_control_event_script_finished(ctdb);
+ ctdb_control_event_script_finished(ctdb, state);
}
talloc_free(state);
@@ -673,7 +668,7 @@ static int ctdb_event_script_callback_v(struct ctdb_context *ctdb,
/* Nothing to do? */
if (state->scripts->num_scripts == 0) {
if (!state->from_user && state->call == CTDB_EVENT_MONITOR) {
- ctdb_control_event_script_finished(ctdb);
+ ctdb_control_event_script_finished(ctdb, state);
}
ctdb->event_script_timeouts = 0;
talloc_free(state);