1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-26 21:57:41 +03:00

ctdb-common: Return script_list for zero scripts

When an event script directory is empty, do not return script_list as
NULL.  Instead return empty script_list with zero scripts.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
This commit is contained in:
Amitay Isaacs 2018-05-10 12:43:24 +10:00 committed by Martin Schwenke
parent 4d27c11ce2
commit a3591ed5de
3 changed files with 13 additions and 13 deletions

View File

@ -659,6 +659,11 @@ struct tevent_req *run_event_send(TALLOC_CTX *mem_ctx,
state->timeout = timeout;
state->cancelled = false;
state->script_list = talloc_zero(state, struct run_event_script_list);
if (tevent_req_nomem(state->script_list, req)) {
return tevent_req_post(req, ev);
}
/*
* If monitor event is running,
* cancel the running monitor event and run new event
@ -673,11 +678,6 @@ struct tevent_req *run_event_send(TALLOC_CTX *mem_ctx,
if (monitor_running) {
run_event_cancel(current_req);
} else if (strcmp(event_str, "monitor") == 0) {
state->script_list = talloc_zero(
state, struct run_event_script_list);
if (tevent_req_nomem(state->script_list, req)) {
return tevent_req_post(req, ev);
}
state->script_list->summary = -ECANCELED;
tevent_req_done(req);
return tevent_req_post(req, ev);
@ -714,14 +714,16 @@ static void run_event_trigger(struct tevent_req *req, void *private_data)
struct tevent_req *subreq;
struct run_event_state *state = tevent_req_data(
req, struct run_event_state);
struct run_event_script_list *script_list;
int ret;
bool is_monitor = false;
D_DEBUG("Running event %s with args \"%s\"\n", state->event_str,
state->arg_str == NULL ? "(null)" : state->arg_str);
ret = get_script_list(state, run_event_script_dir(state->run_ctx),
&state->script_list);
ret = get_script_list(state,
run_event_script_dir(state->run_ctx),
&script_list);
if (ret != 0) {
D_ERR("get_script_list() failed, ret=%d\n", ret);
tevent_req_error(req, ret);
@ -729,12 +731,14 @@ static void run_event_trigger(struct tevent_req *req, void *private_data)
}
/* No scripts */
if (state->script_list == NULL ||
state->script_list->num_scripts == 0) {
if (script_list == NULL || script_list->num_scripts == 0) {
tevent_req_done(req);
return;
}
talloc_free(state->script_list);
state->script_list = script_list;
ret = script_args(state, state->event_str, state->arg_str,
&state->argv);
if (ret != 0) {

View File

@ -16,12 +16,10 @@ EOF
simple_test run monitor 30
required_result 0 <<EOF
Event monitor has never run
EOF
simple_test status monitor
required_result 0 <<EOF
Event monitor has never passed
EOF
simple_test status monitor lastpass

View File

@ -39,12 +39,10 @@ EOF
simple_test run monitor 30
required_result 0 <<EOF
Event monitor has never run
EOF
simple_test status monitor lastrun
required_result 0 <<EOF
Event monitor has never passed
EOF
simple_test status monitor lastpass