]> Kevux Git Server - fll/commitdiff
Update: controller program should continue on error.
authorKevin Day <thekevinday@gmail.com>
Sun, 4 Apr 2021 23:16:13 +0000 (18:16 -0500)
committerKevin Day <thekevinday@gmail.com>
Sun, 4 Apr 2021 23:20:29 +0000 (18:20 -0500)
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
level_3/controller/c/private-rule.c
level_3/controller/c/private-rule.h

index 6fb3bc194dd48fd3ef317eb531ab5fbc2318996d..c4edbfe6b4deb84a2ddb7fd5e825e7b4cd4f538f 100644 (file)
@@ -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;
         }
       }
index af5724b1e14213d6156842b5f6dd54f251551749..2dac31c99eb02af2cdd7053d3e9d6513d2ba59be 100644 (file)
@@ -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);
 
index 5d8e467435c6ebc9f514f51950d5f1326d37f65f..0ec6434d4ccaae780fb24ddd48744c1488d1bb6e 100644 (file)
@@ -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;