From 71fda6ad397c3158488b3145b7f17303f01731d1 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sun, 4 Apr 2021 18:16:13 -0500 Subject: [PATCH] Update: controller program should continue on error. Except for certain error codes, like out of memory, record errors and continue onward. Future versions should somehow handle out of memory issues if this program is to become an "init" replacement. Avoid unnecessary assignment of rules error status. In some cases, the rules error status was being assigned twice. --- level_3/controller/c/private-controller.c | 2 +- level_3/controller/c/private-rule.c | 43 +++++++++++++++++++------------ level_3/controller/c/private-rule.h | 1 + 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/level_3/controller/c/private-controller.c b/level_3/controller/c/private-controller.c index 6fb3bc1..c4edbfe 100644 --- a/level_3/controller/c/private-controller.c +++ b/level_3/controller/c/private-controller.c @@ -1197,7 +1197,7 @@ extern "C" { cache->action.name_action.used = 0; if (F_status_is_error(status)) { - if (!simulate || F_status_set_fine(status) == F_memory_not) { + if (F_status_set_fine(status) == F_memory_not) { break; } } diff --git a/level_3/controller/c/private-rule.c b/level_3/controller/c/private-rule.c index af5724b..2dac31c 100644 --- a/level_3/controller/c/private-rule.c +++ b/level_3/controller/c/private-rule.c @@ -879,7 +879,7 @@ extern "C" { if (!(options & controller_rule_option_simulate)) break; - success = F_status_set_error(F_failure); + success = F_failure; } else if (success == F_false || success == F_ignore) { success = F_true; @@ -923,14 +923,13 @@ extern "C" { if (!(options & controller_rule_option_simulate)) break; - success = F_status_set_error(F_failure); + success = F_failure; } else if (success == F_false || success == F_ignore) { success = F_true; } } else { - if (main.data->warning.verbosity == f_console_verbosity_debug) { f_thread_mutex_lock(&main.thread->lock.print); @@ -957,12 +956,12 @@ extern "C" { f_macro_string_maps_t_delete_simple(environment); - if (status == F_child || status == F_signal) { + if (status == F_child || status == F_signal || F_status_is_error(status)) { return status; } - if (F_status_is_error(status) || success == F_false) { - return F_status_set_error(F_failure); + if (success == F_false || success == F_failure) { + return F_failure; } if (success == F_ignore) { @@ -2185,8 +2184,20 @@ extern "C" { } } - if (F_status_is_error_not(status) && main.thread->enabled) { - status = controller_rule_process(controller_rule_action_type_start, main, process); + if (F_status_is_error(status)) { + f_thread_unlock(&main.thread->lock.rule); + f_thread_lock_write(&main.thread->lock.rule); + + if (controller_rule_find(process->rule.alias, main.setting->rules, &id_rule) == F_true) { + main.setting->rules.array[id_rule].status = status; + } + + f_thread_unlock(&main.thread->lock.rule); + } + else { + if (main.thread->enabled) { + status = controller_rule_process(controller_rule_action_type_start, main, process); + } } } else { @@ -2194,6 +2205,14 @@ extern "C" { status = F_status_set_error(F_found_not); + f_thread_lock_write(&main.thread->lock.rule); + + if (controller_rule_find(process->rule.alias, main.setting->rules, &id_rule) == F_true) { + main.setting->rules.array[id_rule].status = status; + } + + f_thread_unlock(&main.thread->lock.rule); + if (main.data->error.verbosity != f_console_verbosity_quiet) { f_thread_mutex_lock(&main.thread->lock.print); @@ -2204,14 +2223,6 @@ extern "C" { } } - f_thread_lock_write(&main.thread->lock.rule); - - if (controller_rule_find(process->rule.alias, main.setting->rules, &id_rule) == F_true) { - main.setting->rules.array[id_rule].status = status; - } - - f_thread_unlock(&main.thread->lock.rule); - f_thread_unlock(&process->lock); f_thread_lock_write(&process->lock); diff --git a/level_3/controller/c/private-rule.h b/level_3/controller/c/private-rule.h index 5d8e467..0ec6434 100644 --- a/level_3/controller/c/private-rule.h +++ b/level_3/controller/c/private-rule.h @@ -583,6 +583,7 @@ extern "C" { * F_none on success. * F_child on child process exiting. * F_signal on (exit) signal received. + * F_failure on execution failure. */ #ifndef _di_controller_rule_process_ extern f_status_t controller_rule_process(const uint8_t action, const controller_main_t main, controller_process_t *process) f_gcc_attribute_visibility_internal; -- 1.8.3.1