]> Kevux Git Server - fll/commitdiff
Cleanup: Remove dead code in controller program.
authorKevin Day <kevin@kevux.org>
Thu, 9 Mar 2023 02:55:09 +0000 (20:55 -0600)
committerKevin Day <kevin@kevux.org>
Thu, 9 Mar 2023 02:55:09 +0000 (20:55 -0600)
The process variable is not used.
Remove all of the dead code.

level_3/controller/c/entry/private-entry.c
level_3/controller/c/rule/private-rule.c
level_3/controller/c/rule/private-rule.h
level_3/controller/c/thread/private-thread.c
level_3/controller/c/thread/private-thread_process.c
level_3/controller/c/thread/private-thread_process.h
level_3/controller/c/thread/private-thread_signal.c

index 47be22db6e0546248ecd0a4190d845b6af05d129..d1e8c92d3a51ade079a579bf927d177f8fef385e 100644 (file)
@@ -850,7 +850,6 @@ extern "C" {
     controller_entry_t *entry = is_entry ? &global->setting->entry : &global->setting->exit;
     controller_entry_action_t *entry_action = 0;
     controller_entry_actions_t *entry_actions = 0;
-    controller_process_t *process = 0;
 
     // An empty stack is used here because each rule here is the first rule run in the rule's scope.
     const f_array_lengths_t stack = f_array_lengths_t_initialize;
@@ -1017,7 +1016,7 @@ extern "C" {
             }
 
             if (!(global->main->parameters.array[controller_parameter_validate_e].result & f_console_result_found_e)) {
-              status = controller_rule_wait_all(*global, is_entry, F_false, process);
+              status = controller_rule_wait_all(*global, is_entry, F_false);
               if (F_status_is_error(status)) return status;
             }
           }
@@ -1325,7 +1324,7 @@ extern "C" {
 
           if (global->main->parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e) return F_execute;
 
-          controller_thread_process_cancel(*global, is_entry, is_entry ? controller_thread_cancel_execute_e : controller_thread_cancel_exit_execute_e, process);
+          controller_thread_process_cancel(*global, is_entry, is_entry ? controller_thread_cancel_execute_e : controller_thread_cancel_exit_execute_e);
 
           int result = 0;
           int option = FL_execute_parameter_option_path_d;
@@ -1487,7 +1486,7 @@ extern "C" {
 
     // Check to see if any required processes failed, but do not do this if already operating in failsafe.
     if (F_status_is_error_not(status) && !failsafe && !(global->main->parameters.array[controller_parameter_validate_e].result & f_console_result_found_e)) {
-      const f_status_t status_wait = controller_rule_wait_all(*global, is_entry, F_true, 0);
+      const f_status_t status_wait = controller_rule_wait_all(*global, is_entry, F_true);
       if (F_status_is_error(status_wait)) return status_wait;
       if (status_wait == F_require) return F_status_set_error(F_require);
     }
index 04481f562efa762f02cfe4b7b015b9ac83e2545a..8c54cb92de4605d4bcdaccdeeb54570e6e8673d2 100644 (file)
@@ -6177,16 +6177,9 @@ extern "C" {
 #endif // _di_controller_rule_validate_
 
 #ifndef _di_controller_rule_wait_all_
-  f_status_t controller_rule_wait_all(const controller_global_t global, const bool is_normal, const bool required, controller_process_t * const caller) {
+  f_status_t controller_rule_wait_all(const controller_global_t global, const bool is_normal, const bool required) {
 
-    f_status_t status_lock = F_none;
-
-    if (caller) {
-      status_lock = controller_lock_read_process(caller, global.thread, &global.thread->lock.process);
-    }
-    else {
-      status_lock = controller_lock_read(is_normal, global.thread, &global.thread->lock.process);
-    }
+    f_status_t status_lock = controller_lock_read(is_normal, global.thread, &global.thread->lock.process);
 
     if (F_status_is_error(status_lock)) {
       controller_lock_print_error_critical(global.main->error, F_status_set_fine(status_lock), F_true, global.thread);
@@ -6220,21 +6213,10 @@ extern "C" {
 
     for (i = 0; i < process_total; ++i) {
 
-      if (caller) {
-        if (!controller_thread_is_enabled_process(caller, global.thread)) break;
-      }
-      else {
-        if (!controller_thread_is_enabled(is_normal, global.thread)) break;
-      }
+      if (!controller_thread_is_enabled(is_normal, global.thread)) break;
 
       // Re-establish global process read lock to wait for or protect from the cleanup thread while checking the read process.
-      if (caller) {
-        status_lock = controller_lock_read_process(caller, global.thread, &global.thread->lock.process);
-      }
-      else {
-        status_lock = controller_lock_read(is_normal, global.thread, &global.thread->lock.process);
-      }
-
+      status_lock = controller_lock_read(is_normal, global.thread, &global.thread->lock.process);
       if (F_status_is_error(status_lock)) break;
 
       if (!process_list[i]) {
@@ -6243,12 +6225,7 @@ extern "C" {
         continue;
       }
 
-      if (caller) {
-        status_lock = controller_lock_read_process(caller, global.thread, &process_list[i]->active);
-      }
-      else {
-        status_lock = controller_lock_read(is_normal, global.thread, &process_list[i]->active);
-      }
+      status_lock = controller_lock_read(is_normal, global.thread, &process_list[i]->active);
 
       if (F_status_is_error(status_lock)) {
         f_thread_unlock(&global.thread->lock.process);
@@ -6259,60 +6236,7 @@ extern "C" {
       // Once the active lock is obtained, then the main process read lock can be safely released.
       f_thread_unlock(&global.thread->lock.process);
 
-      if (caller) {
-        if (caller) {
-          status_lock = controller_lock_read_process(caller, global.thread, &global.thread->lock.rule);
-        }
-        else {
-          status_lock = controller_lock_read(is_normal, global.thread, &global.thread->lock.rule);
-        }
-
-        if (F_status_is_error(status_lock)) {
-          f_thread_unlock(&process_list[i]->active);
-
-          break;
-        }
-
-        if (fl_string_dynamic_compare(caller->rule.alias, process_list[i]->rule.alias) == F_equal_to) {
-          f_thread_unlock(&global.thread->lock.rule);
-          f_thread_unlock(&process_list[i]->active);
-
-          continue;
-        }
-
-        skip = F_false;
-
-        for (j = 0; j < caller->stack.used; ++j) {
-
-          if (caller) {
-            if (!controller_thread_is_enabled_process(caller, global.thread)) break;
-          }
-          else {
-            if (!controller_thread_is_enabled(is_normal, global.thread)) break;
-          }
-
-          if (global.thread->processs.array[caller->stack.array[j]] && fl_string_dynamic_compare(process_list[i]->rule.alias, global.thread->processs.array[caller->stack.array[j]]->rule.alias) == F_equal_to) {
-            skip = F_true;
-          }
-
-          if (skip) break;
-        } // for
-
-        f_thread_unlock(&global.thread->lock.rule);
-
-        if (skip) {
-          f_thread_unlock(&process_list[i]->active);
-
-          continue;
-        }
-      }
-
-      if (caller) {
-        status_lock = controller_lock_read_process(caller, global.thread, &process_list[i]->lock);
-      }
-      else {
-        status_lock = controller_lock_read(is_normal, global.thread, &process_list[i]->lock);
-      }
+      status_lock = controller_lock_read(is_normal, global.thread, &process_list[i]->lock);
 
       if (F_status_is_error(status_lock)) {
         f_thread_unlock(&process_list[i]->active);
@@ -6334,12 +6258,7 @@ extern "C" {
         if (process_list[i]->state == controller_process_state_done_e) {
           f_thread_unlock(&process_list[i]->lock);
 
-          if (caller) {
-            status_lock = controller_lock_write_process(process_list[i], global.thread, &process_list[i]->lock);
-          }
-          else {
-            status_lock = controller_lock_write(is_normal, global.thread, &process_list[i]->lock);
-          }
+          status_lock = controller_lock_write(is_normal, global.thread, &process_list[i]->lock);
 
           if (F_status_is_error(status_lock)) {
             controller_lock_print_error_critical(global.main->error, F_status_set_fine(status_lock), F_false, global.thread);
@@ -6365,12 +6284,7 @@ extern "C" {
               f_thread_mutex_unlock(&process_list[i]->wait_lock);
             }
 
-            if (caller) {
-              status_lock = controller_lock_read_process(caller, global.thread, &process_list[i]->active);
-            }
-            else {
-              status_lock = controller_lock_read(is_normal, global.thread, &process_list[i]->active);
-            }
+            status_lock = controller_lock_read(is_normal, global.thread, &process_list[i]->active);
 
             if (F_status_is_error(status_lock)) {
               f_thread_unlock(&process_list[i]->lock);
@@ -6381,13 +6295,7 @@ extern "C" {
 
           f_thread_unlock(&process_list[i]->lock);
 
-          if (caller) {
-            status_lock = controller_lock_read_process(caller, global.thread, &process_list[i]->lock);
-          }
-          else {
-            status_lock = controller_lock_read(is_normal, global.thread, &process_list[i]->lock);
-          }
-
+          status_lock = controller_lock_read(is_normal, global.thread, &process_list[i]->lock);
           if (F_status_is_error(status_lock)) break;
         }
 
@@ -6424,12 +6332,7 @@ extern "C" {
           break;
         }
 
-        if (caller) {
-          status_lock = controller_lock_read_process(caller, global.thread, &process_list[i]->lock);
-        }
-        else {
-          status_lock = controller_lock_read(is_normal, global.thread, &process_list[i]->lock);
-        }
+        status_lock = controller_lock_read(is_normal, global.thread, &process_list[i]->lock);
 
         if (F_status_is_error(status_lock)) {
           f_thread_unlock(&process_list[i]->active);
@@ -6467,15 +6370,8 @@ extern "C" {
       return status_lock;
     }
 
-    if (caller) {
-      if (!controller_thread_is_enabled_process(caller, global.thread)) {
-        return F_status_set_error(F_interrupt);
-      }
-    }
-    else {
-      if (!controller_thread_is_enabled(is_normal, global.thread)) {
-        return F_status_set_error(F_interrupt);
-      }
+    if (!controller_thread_is_enabled(is_normal, global.thread)) {
+      return F_status_set_error(F_interrupt);
     }
 
     if (F_status_set_fine(status) == F_require) {
@@ -6491,9 +6387,9 @@ extern "C" {
 #endif // _di_controller_rule_wait_all_
 
 #ifndef _di_controller_rule_wait_all_process_type_
-  f_status_t controller_rule_wait_all_process_type(const controller_global_t global, const uint8_t type, const bool required, controller_process_t * const caller) {
+  f_status_t controller_rule_wait_all_process_type(const controller_global_t global, const uint8_t type, const bool required) {
 
-    return controller_rule_wait_all(global, type != controller_process_type_exit_e, required, caller);
+    return controller_rule_wait_all(global, type != controller_process_type_exit_e, required);
   }
 #endif // _di_controller_rule_wait_all_process_type_
 
index 83c619144c9b460fe0ca3cef8b009d372aba8a80..f47e311d307c5e5aa3f646c17b5470715dc8744d 100644 (file)
@@ -759,10 +759,6 @@ extern "C" {
  * @param required
  *   If TRUE, then only process required rules and if a required rule has failed, return.
  *   If FALSE, process all waits, returning normally (required rules still result in failure).
- * @param caller
- *   The process representing the caller so that the process never waits on itself.
- *   (optional) set to 0 when calling from a thread that is not running/executing any process.
- *   Failure to set this to the process on a thread running/executing a process will likely result in a deadlock.
  *
  * @return
  *   F_none on success.
@@ -773,7 +769,7 @@ extern "C" {
  *   F_require (with error bit set) if a required process is in failed status when required is TRUE.
  */
 #ifndef _di_controller_rule_wait_all_
-  extern f_status_t controller_rule_wait_all(const controller_global_t global, const bool is_normal, const bool required, controller_process_t * const caller) F_attribute_visibility_internal_d;
+  extern f_status_t controller_rule_wait_all(const controller_global_t global, const bool is_normal, const bool required) F_attribute_visibility_internal_d;
 #endif // _di_controller_rule_wait_all_
 
 /**
@@ -786,10 +782,6 @@ extern "C" {
  * @param required
  *   If TRUE, then only process required rules and if a required rule has failed, return.
  *   If FALSE, process all waits, returning normally.
- * @param caller
- *   The process representing the caller so that the process never waits on itself.
- *   (optional) set to 0 when calling from a thread that is not running/executing any process.
- *   Failure to set this to the process on a thread running/executing a process will likely result in a deadlock.
  *
  * @return
  *   Success from controller_rule_wait_all().
@@ -799,7 +791,7 @@ extern "C" {
  * @see controller_rule_wait_all()
  */
 #ifndef _di_controller_rule_wait_all_process_type_
-  extern f_status_t controller_rule_wait_all_process_type(const controller_global_t global, const uint8_t type, const bool required, controller_process_t * const caller) F_attribute_visibility_internal_d;
+  extern f_status_t controller_rule_wait_all_process_type(const controller_global_t global, const uint8_t type, const bool required) F_attribute_visibility_internal_d;
 #endif // _di_controller_rule_wait_all_process_type_
 
 #ifdef __cplusplus
index 552718ae7dc021508592f5dc94d26c90ea1dea5a..da90885fd899158d59dc82876261ff899bc231dc 100644 (file)
@@ -292,11 +292,11 @@ extern "C" {
         controller_thread_join(&thread.id_signal);
       }
       else if (setting->mode == controller_setting_mode_program_e) {
-        status = controller_rule_wait_all(global, F_true, F_false, 0);
+        status = controller_rule_wait_all(global, F_true, F_false);
       }
     }
 
-    controller_thread_process_cancel(global, F_true, controller_thread_cancel_call_e, 0);
+    controller_thread_process_cancel(global, F_true, controller_thread_cancel_call_e);
 
     controller_thread_process_exit(&global);
 
index 9f4c1f30fe10f90f3c728e8710467b8e63b229c8..f59f02b372939fe36c5a276f8d20c739af29e7ef 100644 (file)
@@ -43,7 +43,7 @@ extern "C" {
 #endif // _di_controller_thread_process_
 
 #ifndef _di_controller_thread_process_cancel_
-  void controller_thread_process_cancel(const controller_global_t global, const bool is_normal, const uint8_t by, controller_process_t * const caller) {
+  void controller_thread_process_cancel(const controller_global_t global, const bool is_normal, const uint8_t by) {
 
     f_thread_mutex_lock(&global.thread->lock.cancel);
 
@@ -126,7 +126,6 @@ extern "C" {
     for (; i < global.thread->processs.used; ++i) {
 
       if (!global.thread->processs.array[i]) continue;
-      if (caller && i == caller->id) continue;
 
       process = global.thread->processs.array[i];
 
@@ -160,7 +159,6 @@ extern "C" {
       for (i = 0; i < global.thread->processs.used && lapsed < entry->timeout_exit; ++i) {
 
         if (!global.thread->processs.array[i]) continue;
-        if (caller && i == caller->id) continue;
 
         process = global.thread->processs.array[i];
 
@@ -222,7 +220,6 @@ extern "C" {
     for (i = 0; i < global.thread->processs.size; ++i) {
 
       if (!global.thread->processs.array[i]) continue;
-      if (caller && i == caller->id) continue;
 
       process = global.thread->processs.array[i];
 
@@ -393,7 +390,7 @@ extern "C" {
         global->thread->id_signal = 0;
       }
 
-      controller_thread_process_cancel(*global, F_false, controller_thread_cancel_exit_e, 0);
+      controller_thread_process_cancel(*global, F_false, controller_thread_cancel_exit_e);
     }
     else {
       if (F_status_is_error_not(f_thread_mutex_lock(&global->thread->lock.alert))) {
index 0030bbe520f00d653b6c833ad0642f08c12a58de..674637b8501098964ef2b121b54936edc4b38fd1 100644 (file)
@@ -41,12 +41,9 @@ extern "C" {
  *   If controller_thread_cancel_signal_e, then this was called from within the signal handling thread, so do not cancel the signal thread.
  *   If controller_thread_cancel_call_e, then this was not called from within the signal handling thread, so cancel the signal thread.
  *   If controller_thread_cancel_execute_e, then this was called from within the Entry/Exit for executing a process, so cancel the signal thread but not the Entry thread.
- * @param caller
- *   (optional) The process that is calling the cancel so that this process itself does not get cancelled.
- *   Set to NULL to not use.
  */
 #ifndef _di_controller_thread_process_cancel_
-  extern void controller_thread_process_cancel(const controller_global_t global, const bool is_normal, const uint8_t by, controller_process_t * const caller) F_attribute_visibility_internal_d;
+  extern void controller_thread_process_cancel(const controller_global_t global, const bool is_normal, const uint8_t by) F_attribute_visibility_internal_d;
 #endif // _di_controller_thread_process_cancel_
 
 /**
index 75cbc29aae999308d9eba3175d54111bf5db4ca7..398b41ad3e7929240ac71f987881b53ec1222fc4 100644 (file)
@@ -33,7 +33,7 @@ extern "C" {
         if (information.si_signo == F_signal_interrupt || information.si_signo == F_signal_abort || information.si_signo == F_signal_quit || information.si_signo == F_signal_termination) {
           global->thread->signal = information.si_signo;
 
-          controller_thread_process_cancel(*global, is_normal, controller_thread_cancel_signal_e, 0);
+          controller_thread_process_cancel(*global, is_normal, controller_thread_cancel_signal_e);
 
           break;
         }