]> Kevux Git Server - fll/commitdiff
Update: use the action of the process type, preparing for implementing exit files...
authorKevin Day <thekevinday@gmail.com>
Sun, 18 Apr 2021 04:22:36 +0000 (23:22 -0500)
committerKevin Day <thekevinday@gmail.com>
Sun, 18 Apr 2021 04:24:42 +0000 (23:24 -0500)
level_3/controller/c/private-controller.c
level_3/controller/c/private-controller.h
level_3/controller/c/private-rule.c
level_3/controller/c/private-rule.h
level_3/controller/c/private-thread.c

index 63469fbf651681a26d26336c7f276ae196cb9273..c365663cd6ecd261952b8538701643297a7192d2 100644 (file)
@@ -673,7 +673,7 @@ extern "C" {
 #endif // _di_controller_preprocess_entry_
 
 #ifndef _di_controller_process_entry_
-  f_status_t controller_process_entry(const bool failsafe, controller_main_t *main, controller_cache_t *cache) {
+  f_status_t controller_process_entry(const bool failsafe, const uint8_t action, controller_main_t *main, controller_cache_t *cache) {
 
     f_status_t status = F_none;
     f_status_t status_lock = F_none;
index 09d5b7efc99c4ce746f8b0bac82a31be535a078e..cef422a97b071eab67984ec775f5dffc521c2ad7 100644 (file)
@@ -317,11 +317,13 @@ extern "C" {
 #endif // _di_controller_preprocess_entry_
 
 /**
- * Process (execute) all items for the loaded entry.
+ * Process (execute) all items for the loaded entry or exit.
  *
  * @param failsafe
  *   If TRUE, operate in failsafe mode (starts at designated failsafe Item).
  *   If FALSE, operate in normal mode (starts at "main" Item).
+ * @param action
+ *   The action to perform, should be either controller_rule_action_type_start (for entry) or controller_rule_action_type_stop (for exit).
  * @param main
  *   The main data.
  * @param cache
@@ -342,7 +344,7 @@ extern "C" {
  * @see controller_string_dynamic_append_terminated()
  */
 #ifndef _di_controller_process_entry_
-  extern f_status_t controller_process_entry(const bool failsafe, controller_main_t *main, controller_cache_t *cache) f_gcc_attribute_visibility_internal;
+  extern f_status_t controller_process_entry(const bool failsafe, const uint8_t action, controller_main_t *main, controller_cache_t *cache) f_gcc_attribute_visibility_internal;
 #endif // _di_controller_process_entry_
 
 /**
index 95f5ea797c4e1033d59ce1d66329d34e3fd0ed59..054814be5300164739ff4ce814e94c2108aeb62e 100644 (file)
@@ -1763,9 +1763,9 @@ extern "C" {
 #endif // _di_controller_rule_setting_limit_type_name_
 
 #ifndef _di_controller_rule_process_
-  f_status_t controller_rule_process(const uint8_t action, const controller_main_t main, controller_process_t *process) {
+  f_status_t controller_rule_process(const controller_main_t main, controller_process_t *process) {
 
-    switch (action) {
+    switch (process->action) {
       case controller_rule_action_type_freeze:
       case controller_rule_action_type_kill:
       case controller_rule_action_type_pause:
@@ -1784,7 +1784,7 @@ extern "C" {
 
           fprintf(main.data->error.to.stream, "%c", f_string_eol_s[0]);
           fprintf(main.data->error.to.stream, "%s%sUnsupported action type '", main.data->error.context.before->string, main.data->error.prefix ? main.data->error.prefix : f_string_empty_s);
-          fprintf(main.data->error.to.stream, "%s%s%s%s", main.data->error.context.after->string, main.data->error.notable.before->string, controller_rule_action_type_name(action), main.data->error.notable.after->string);
+          fprintf(main.data->error.to.stream, "%s%s%s%s", main.data->error.context.after->string, main.data->error.notable.before->string, controller_rule_action_type_name(process->action), main.data->error.notable.after->string);
           fprintf(main.data->error.to.stream, "%s' while attempting to execute rule.%s%c", main.data->error.context.before->string, main.data->error.context.after->string, f_string_eol_s[0]);
 
           controller_rule_error_print_cache(main.data->error, process->cache.action, F_true);
@@ -1843,7 +1843,7 @@ extern "C" {
     }
 
     if ((process->options & controller_process_option_simulate) && main.data->parameters[controller_parameter_validate].result == f_console_result_found) {
-      controller_rule_validate(process->rule, action, process->options, main, &process->cache);
+      controller_rule_validate(process->rule, process->action, process->options, main, &process->cache);
     }
 
     f_array_length_t i = 0;
@@ -2015,7 +2015,7 @@ extern "C" {
                 }
 
                 // synchronously execute dependency.
-                status = controller_rule_process_begin(0, alias_other, action, options_process, process->stack, main, process_other->cache);
+                status = controller_rule_process_begin(0, alias_other, process->action, options_process, process->stack, main, process_other->cache);
 
                 if (status == F_child || status == F_signal) {
                   f_thread_unlock(&process_other->active);
@@ -2152,7 +2152,7 @@ extern "C" {
 
           for (j = 0; j < process->rule.items.array[i].actions.used; ++j) {
 
-            if (process->rule.items.array[i].actions.array[j].type == action) {
+            if (process->rule.items.array[i].actions.array[j].type == process->action) {
               missing = F_false;
               break;
             }
@@ -2167,7 +2167,7 @@ extern "C" {
             fprintf(main.data->error.to.stream, "%s%sThe rule '", main.data->error.context.before->string, main.data->error.prefix ? main.data->error.prefix : f_string_empty_s);
             fprintf(main.data->error.to.stream, "%s%s%s%s", main.data->error.context.after->string, main.data->error.notable.before->string, process->rule.name.used ? process->rule.name.string : f_string_empty_s, main.data->error.notable.after->string);
             fprintf(main.data->error.to.stream, "%s' has no '", main.data->error.context.before->string);
-            fprintf(main.data->error.to.stream, "%s%s%s%s", main.data->error.context.after->string, main.data->error.notable.before->string, controller_rule_action_type_name(action).string, main.data->error.notable.after->string);
+            fprintf(main.data->error.to.stream, "%s%s%s%s", main.data->error.context.after->string, main.data->error.notable.before->string, controller_rule_action_type_name(process->action).string, main.data->error.notable.after->string);
             fprintf(main.data->error.to.stream, "%s' action to execute.%s%c", main.data->error.context.before->string, main.data->error.context.after->string, f_string_eol_s[0]);
 
             controller_rule_error_print_cache(main.data->error, process->cache.action, F_true);
@@ -2180,7 +2180,7 @@ extern "C" {
       }
 
       if (F_status_is_error_not(status)) {
-        status = controller_rule_execute(action, process->options, main, process);
+        status = controller_rule_execute(process->action, process->options, main, process);
 
         if (status == F_child || status == F_signal || status == F_status_set_error(F_lock)) {
           return status;
@@ -2618,8 +2618,7 @@ extern "C" {
       }
 
       if (F_status_is_error_not(status)) {
-        // @todo this needs to support passing different (supported) types, particularly when the "control" is written, (an entry will always send start and an exit will always send stop).
-        status = controller_rule_process(controller_rule_action_type_start, main, process);
+        status = controller_rule_process(main, process);
       }
     }
     else {
index 2eb8c8762ab4fb113763e45d93427d7faefcd391..0923566ca25f5ba90cf97a265941542d1d077f7c 100644 (file)
@@ -589,15 +589,6 @@ extern "C" {
  *
  * The rule status will be updated by this function.
  *
- * @param action
- *   The action to perform based on the action type codes.
- *
- *   Only subset of the action type codes are supported:
- *   - controller_rule_action_type_kill
- *   - controller_rule_action_type_reload
- *   - controller_rule_action_type_restart
- *   - controller_rule_action_type_start
- *   - controller_rule_action_type_stop
  * @param main
  *   The main data.
  * @param process
@@ -615,7 +606,7 @@ extern "C" {
  *   Errors (with error bit) from: controller_lock_write().
  */
 #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;
+  extern f_status_t controller_rule_process(const controller_main_t main, controller_process_t *process) f_gcc_attribute_visibility_internal;
 #endif // _di_controller_rule_process_
 
 /**
index a11f091502849b81c25a829f16a8f175791f7ef9..f70c54678151811323838e59441ed6c10a268de2 100644 (file)
@@ -552,13 +552,13 @@ extern "C" {
           *status = F_status_set_error(F_available_not);
         }
         else {
-          *status = controller_process_entry(F_false, entry->main, cache);
+          *status = controller_process_entry(F_false, controller_rule_action_type_start, entry->main, cache);
 
           if (F_status_is_error(*status)) {
             entry->setting->ready = controller_setting_ready_fail;
 
             if (F_status_set_fine(*status) == F_require && entry->main->setting->failsafe_enabled) {
-              const f_status_t status_failsafe = controller_process_entry(F_true, entry->main, cache);
+              const f_status_t status_failsafe = controller_process_entry(F_true, controller_rule_action_type_start, entry->main, cache);
 
               if (F_status_is_error(status_failsafe)) {
                 if (data->error.verbosity != f_console_verbosity_quiet) {