diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2009-12-10 20:25:33 +1030 |
---|---|---|
committer | Ronnie Sahlberg <ronniesahlberg@gmail.com> | 2009-12-14 15:46:14 +1100 |
commit | 784fa9fd8a5bb6d244cbfe5d973ae751d4539472 (patch) | |
tree | 5fc3279c0850a8f4cb9e6fd09b5fbf8242d1c98d /ctdb/server/eventscript.c | |
parent | e76561f544dc208ac3867f25738d9b9d745ea1d1 (diff) | |
download | samba-784fa9fd8a5bb6d244cbfe5d973ae751d4539472.tar.gz samba-784fa9fd8a5bb6d244cbfe5d973ae751d4539472.tar.xz samba-784fa9fd8a5bb6d244cbfe5d973ae751d4539472.zip |
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)
Diffstat (limited to 'ctdb/server/eventscript.c')
-rw-r--r-- | ctdb/server/eventscript.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/ctdb/server/eventscript.c b/ctdb/server/eventscript.c index 1e74446de3..5bec0e0ab9 100644 --- a/ctdb/server/eventscript.c +++ b/ctdb/server/eventscript.c @@ -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; |