1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

eventscript: fix cleanup path when setting up script list

We shouldn't set ctdb->current_monitor until we set destructor: that's
what cleans it up.

Also, free state->scripts on no-scripts exit path: it's not a child of
state because we need it in the destructor.

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

(This used to be ctdb commit 843a2ed5ef85f628788b0caf7417c6b61b5c6d3f)
This commit is contained in:
Rusty Russell 2009-12-18 11:54:24 +10:30 committed by Ronnie Sahlberg
parent 77c4a86351
commit 4dce0690de

View File

@ -638,10 +638,6 @@ static int ctdb_event_script_callback_v(struct ctdb_context *ctdb,
ctdb->current_monitor = NULL;
}
if (!from_user && (call == CTDB_EVENT_MONITOR || call == CTDB_EVENT_STATUS)) {
ctdb->current_monitor = state;
}
DEBUG(DEBUG_INFO,(__location__ " Starting eventscript %s %s\n",
ctdb_eventscript_call_names[state->call],
state->options));
@ -657,6 +653,7 @@ static int ctdb_event_script_callback_v(struct ctdb_context *ctdb,
/* Nothing to do? */
if (state->scripts->num_scripts == 0) {
ctdb->event_script_timeouts = 0;
talloc_free(state->scripts);
talloc_free(state);
return 0;
}
@ -668,6 +665,10 @@ static int ctdb_event_script_callback_v(struct ctdb_context *ctdb,
return -1;
}
if (!from_user && (call == CTDB_EVENT_MONITOR || call == CTDB_EVENT_STATUS)) {
ctdb->current_monitor = state;
}
talloc_set_destructor(state, event_script_destructor);
if (!timeval_is_zero(&state->timeout)) {
event_add_timed(ctdb->ev, state, timeval_current_ofs(state->timeout.tv_sec, state->timeout.tv_usec), ctdb_event_script_timeout, state);