1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-20 22:50:26 +03:00

eventscript: fix monitoring when killed by another script command

Commit c1ba1392fe "eventscript: get rid of ctdb_control_event_script_finished
altogether" was wrong: there is one case where we want to free the script
without transferring their status to last_status.  This happens because we
always kill an running monitor command when we run any other command.

This still isn't quite right (and never was): the callback will be called
with status value 0, which might flip us to HEALTHY if we were unhealthy.
This is conveniently fixed in my next set of patches :)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

(This used to be ctdb commit 0ea0e27d93398df997d3df9d8bf112358af3a4a5)
This commit is contained in:
Rusty Russell 2009-12-10 20:25:33 +10:30 committed by Ronnie Sahlberg
parent e76561f544
commit 784fa9fd8a

View File

@ -514,11 +514,13 @@ static int event_script_destructor(struct ctdb_event_script_state *state)
state->ctdb->current_monitor = NULL;
}
/* Save our status as the last executed status. */
talloc_free(state->ctdb->last_status[state->call]);
state->ctdb->last_status[state->call] = state->scripts;
if (state->current < state->ctdb->last_status[state->call]->num_scripts) {
state->ctdb->last_status[state->call]->num_scripts = state->current+1;
/* Save our scripts as the last executed status, if we have them. */
if (state->scripts) {
talloc_free(state->ctdb->last_status[state->call]);
state->ctdb->last_status[state->call] = state->scripts;
if (state->current < state->ctdb->last_status[state->call]->num_scripts) {
state->ctdb->last_status[state->call]->num_scripts = state->current+1;
}
}
/* This is allowed to free us; talloc will prevent double free anyway,
@ -622,8 +624,13 @@ static int ctdb_event_script_callback_v(struct ctdb_context *ctdb,
}
/* Kill off any running monitor events to run this event. */
talloc_free(ctdb->current_monitor);
ctdb->current_monitor = NULL;
if (ctdb->current_monitor) {
/* Discard script status so we don't save to last_status */
talloc_free(ctdb->current_monitor->scripts);
ctdb->current_monitor->scripts = NULL;
talloc_free(ctdb->current_monitor);
ctdb->current_monitor = NULL;
}
if (!from_user && (call == CTDB_EVENT_MONITOR || call == CTDB_EVENT_STATUS)) {
ctdb->current_monitor = state;