const char *event_str;
const char *arg_str;
struct timeval timeout;
+ bool continue_on_failure;
struct run_event_script_list *script_list;
const char **argv;
struct run_event_context *run_ctx,
const char *event_str,
const char *arg_str,
- struct timeval timeout)
+ struct timeval timeout,
+ bool continue_on_failure)
{
struct tevent_req *req, *current_req;
struct run_event_state *state;
}
}
state->timeout = timeout;
+ state->continue_on_failure = continue_on_failure;
state->cancelled = false;
state->script_list = talloc_zero(state, struct run_event_script_list);
/* If a script fails, stop running */
script->summary = run_event_script_status(script);
if (script->summary != 0 && script->summary != -ENOEXEC) {
- state->script_list->num_scripts = state->index + 1;
-
- if (script->summary == -ETIME && pid != -1) {
- run_event_debug(req, pid);
- }
-
state->script_list->summary = script->summary;
- D_NOTICE("%s event %s\n", state->event_str,
- (script->summary == -ETIME) ? "timed out" : "failed");
- run_event_stop_running(state->run_ctx);
- tevent_req_done(req);
- return;
+ if (! state->continue_on_failure) {
+ state->script_list->num_scripts = state->index + 1;
+
+ if (script->summary == -ETIME && pid != -1) {
+ run_event_debug(req, pid);
+ }
+ D_NOTICE("%s event %s\n", state->event_str,
+ (script->summary == -ETIME) ?
+ "timed out" :
+ "failed");
+ run_event_stop_running(state->run_ctx);
+ tevent_req_done(req);
+ return;
+ }
}
state->index += 1;
* @param[in] event_str The event argument to the script
* @param[in] arg_str Event arguments to the script
* @param[in] timeout How long to wait for execution
+ * @param[in] continue_on_failure Whether to continue to run events on failure
* @return new tevent request, or NULL on failure
*
* arg_str contains optional arguments for an event.
struct run_event_context *run_ctx,
const char *event_str,
const char *arg_str,
- struct timeval timeout);
+ struct timeval timeout,
+ bool continue_on_failure);
/**
* @brief Async computation end to run an event
eventd_run_context(state->ectx),
ctdb_event_to_string(state->event),
request->rdata.data.run->arg_str,
- tevent_timeval_current_ofs(timeout, 0));
+ tevent_timeval_current_ofs(timeout, 0),
+ false);
if (tevent_req_nomem(subreq, req)) {
return tevent_req_post(req, ev);
}
arg_str = compact_args(argv, argc, 5);
- req = run_event_send(mem_ctx, ev, run_ctx, argv[4], arg_str, timeout);
+ req = run_event_send(mem_ctx,
+ ev,
+ run_ctx,
+ argv[4],
+ arg_str,
+ timeout,
+ false);
if (req == NULL) {
fprintf(stderr, "run_proc_send() failed\n");
return;