1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-08 21:18:16 +03:00

ctdb-daemon: Do not run monitor event if any other event is already running

Any currently running monitor events are cancelled if any other events
are scheduled.  However, this does not stop monitor events to be run
when other events are already running.

Keep track of the number of active events and schedule monitor event
only if there are no active events.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
This commit is contained in:
Amitay Isaacs 2013-12-19 13:01:25 +11:00 committed by Martin Schwenke
parent e758f41113
commit cbffbb7c2f
2 changed files with 16 additions and 0 deletions

View File

@ -526,6 +526,7 @@ struct ctdb_context {
TALLOC_CTX *release_ips_ctx; /* a context used to automatically drop all IPs if we fail to recover the node */
TALLOC_CTX *event_script_ctx;
int active_events;
struct ctdb_event_script_state *current_monitor;
struct ctdb_scripts_wire *last_status[CTDB_EVENT_MAX];

View File

@ -645,6 +645,11 @@ static int event_script_destructor(struct ctdb_event_script_state *state)
status = 0;
}
state->ctdb->active_events--;
if (state->ctdb->active_events < 0) {
ctdb_fatal(state->ctdb, "Active events < 0");
}
/* This is allowed to free us; talloc will prevent double free anyway,
* but beware if you call this outside the destructor!
* the callback hangs off a different context so we walk the list
@ -750,6 +755,14 @@ static int ctdb_event_script_callback_v(struct ctdb_context *ctdb,
}
}
/* Do not run new monitor events if some event is already running */
if (call == CTDB_EVENT_MONITOR && ctdb->active_events > 0) {
if (callback != NULL) {
callback(ctdb, -ECANCELED, private_data);
}
return 0;
}
/* Kill off any running monitor events to run this event. */
if (ctdb->current_monitor) {
struct ctdb_event_script_state *ms = talloc_get_type(ctdb->current_monitor, struct ctdb_event_script_state);
@ -816,6 +829,8 @@ static int ctdb_event_script_callback_v(struct ctdb_context *ctdb,
talloc_set_destructor(state, event_script_destructor);
ctdb->active_events++;
/* Nothing to do? */
if (state->scripts->num_scripts == 0) {
talloc_free(state);