}
/* 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;
}
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);
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);
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);
/* 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);