]> Kevux Git Server - controller/commitdiff
Progress: Continue migrating the project.
authorKevin Day <Kevin@kevux.org>
Sat, 15 Jun 2024 04:28:34 +0000 (23:28 -0500)
committerKevin Day <Kevin@kevux.org>
Sat, 15 Jun 2024 04:28:34 +0000 (23:28 -0500)
sources/c/main/controller.h
sources/c/main/entry.c
sources/c/main/process.c
sources/c/main/rule/action.c
sources/c/main/rule/item.c
sources/c/main/rule/setting.c
sources/c/main/thread/instance.c

index 47ef9ea55312b4ec82c09dbc2c1d76093c097fc0..289b06527944d8db6ad8d350368d77cd4e442d65 100644 (file)
 #include <program/controller/main/print/error/entry/action.h>
 #include <program/controller/main/print/error/entry/item.h>
 #include <program/controller/main/print/error/entry/setting.h>
+#include <program/controller/main/print/error/lock.h>
 #include <program/controller/main/print/error/perform/pid.h>
 #include <program/controller/main/print/error/rule.h>
 #include <program/controller/main/print/error/rule/action.h>
index 2a6a5d4e45700f632322dd2f8f0ca5e6c36c96ce..153c59b7dc2ad8cc6817a54329b71bd7843c541f 100644 (file)
@@ -100,7 +100,7 @@ extern "C" {
     }
 
     if (F_status_is_error_not(status) && cache->object_items.used) {
-      status = f_memory_array_increase_by(cache->object_items.used, &entry->items.array, &entry->items.used, &entry->items.size);
+      status = f_memory_array_increase_by(cache->object_items.used, sizeof(f_range_t), (void **) &cache->object_items.array, &cache->object_items.used, &cache->object_items.size);
 
       if (F_status_is_error(status)) {
         controller_print_error_entry(&main->program.error, cache, is_entry, F_status_set_fine(status), macro_controller_f(f_memory_array_increase_by), F_true);
@@ -143,10 +143,10 @@ extern "C" {
           cache->action.name_action.used = 0;
           cache->action.name_item.used = 0;
 
-          status = controller_entry_items_increase_by(controller_allocation_small_d, &entry->items);
+          status = f_memory_array_increase(controller_allocation_small_d, sizeof(controller_entry_item_t), (void **) &entry->items.array, &entry->items.used, &entry->items.size);
 
           if (F_status_is_error(status)) {
-            controller_print_error_entry(&main->program.error, cache, is_entry, F_status_set_fine(status), macro_controller_f(controller_entry_items_increase_by), F_true);
+            controller_print_error_entry(&main->program.error, cache, is_entry, F_status_set_fine(status), macro_controller_f(f_memory_array_increase), F_true);
 
             break;
           }
@@ -179,7 +179,7 @@ extern "C" {
                 fl_print_format(f_string_format_Q_single_s.string, main->program.warning.to, main->program.warning.notable, cache->action.name_file, main->program.warning.notable);
                 fl_print_format(f_string_format_sentence_end_quote_s.string, main->program.warning.to, main->program.warning.context, main->program.warning.context, f_string_eol_s);
 
-                controller_print_error_entry_cache(is_entry, &main->program.warning, &cache->action);
+                controller_print_error_entry_cache(&main->program.warning, &cache->action, is_entry);
 
                 controller_unlock_print_flush(main->program.warning.to, &main->thread);
               }
index 3d46a91a114b9e9e416ee874214a5b537d5dd0bf..b5bc2de0f4598346fc326aba9c7b3c919150a146 100644 (file)
@@ -73,7 +73,7 @@ extern "C" {
       }
     }
 
-    // Only make the rule and control threads available once any/all pre-processing are complete.
+    // Only make the rule and control threads available once any/all pre-processing is complete.
     if (F_status_is_error_not(status) && status != F_failure && status != F_child && main->thread.enabled == controller_thread_enabled_e) {
       if (!(main->setting.flag & controller_main_flag_validate_e)) {
 
@@ -135,15 +135,17 @@ extern "C" {
     controller_thread_delete(&main->thread);
 
     if (F_status_set_fine(status) == F_interrupt) {
-      fll_program_print_signal_received(&main->program.warning, main->thread.signal);
+      main->setting.state.status = F_status_set_error(F_interrupt);
 
-      if (main->program.output.verbosity > f_console_verbosity_quiet_e) {
-        fll_print_dynamic_raw(f_string_eol_s, main->program.output.to);
+      if (main->thread.signal) {
+        main->program.signal_received = main->thread.signal;
       }
 
-      fll_program_print_signal_received(&main->program.warning, main->program.signal_received);
+      if (main->program.message.verbosity > f_console_verbosity_error_e) {
+        fll_print_dynamic_raw(f_string_eol_s, main->program.message.to);
+      }
 
-      main->setting.state.status = F_status_set_error(F_interrupt);
+      fll_program_print_signal_received(&main->program.warning, main->program.signal_received);
     }
     else {
       main->setting.state.status = F_status_is_error(status) ? F_status_set_error(F_failure) : F_okay;
index 332b29d6d7a28d09edfcc4075891dcbd1efcae20..566ad02c2afe554b7a99280896dcdffc2272d05f 100644 (file)
@@ -160,10 +160,10 @@ extern "C" {
 
         for (i = 0; i < cache->object_actions.used; ++i) {
 
-          status = f_memory_array_increase_by(controller_allocation_small_d, sizeof(controller_rule_action_t), (void **) &actions->array, &actions->used, &actions->size);
+          status = f_memory_array_increase(controller_allocation_small_d, sizeof(controller_rule_action_t), (void **) &actions->array, &actions->used, &actions->size);
 
           if (F_status_is_error(status)) {
-            controller_print_error(&main->program.error, macro_controller_f(f_memory_array_increase_by));
+            controller_print_error(&main->program.error, macro_controller_f(f_memory_array_increase));
 
             return status;
           }
index dbf29c778108565518295efd5492c5155f714907..32f91311fe8aaccda36bfc09b35bf4e8331f613c 100644 (file)
@@ -161,7 +161,7 @@ extern "C" {
         method = controller_rule_action_method_extended_e;
       }
 
-      status = f_memory_array_increase_by(controller_allocation_small_d, sizeof(controller_rule_action_t), (void **) &item->actions.array, &item->actions.used, &item->actions.size);
+      status = f_memory_array_increase(controller_allocation_small_d, sizeof(controller_rule_action_t), (void **) &item->actions.array, &item->actions.used, &item->actions.size);
 
       if (F_status_is_error(status)) {
         controller_print_error_status(&main->program.error, macro_controller_f(f_memory_array_increase_by), F_status_set_fine(status));
index bb2dd5892bf7893470c3b38ed9804849a41a30af..f7a40171b2790aa61226b1d9c4cb469c7b8e72dc 100644 (file)
@@ -1721,10 +1721,10 @@ extern "C" {
           continue;
         }
 
-        status = f_memory_array_increase_by(controller_allocation_small_d, sizeof(f_string_dynamic_t), (void **) &setting_values->array, &setting_values->used, &setting_values->size);
+        status = f_memory_array_increase(controller_allocation_small_d, sizeof(f_string_dynamic_t), (void **) &setting_values->array, &setting_values->used, &setting_values->size);
 
         if (F_status_is_error(status)) {
-          controller_print_error_rule(&main->program.error, cache->action, F_status_set_fine(status), "f_memory_array_increase_by", F_true, F_false);
+          controller_print_error_rule(&main->program.error, cache->action, F_status_set_fine(status), macro_controller_f(f_memory_array_increase), F_true, F_false);
         }
       }
 
index 53af640c922a3f62a4c0ee23a8e98d0c67688580..8a3ab7c0723b91fbc12be62aa512356710683650 100644 (file)
@@ -46,17 +46,14 @@ extern "C" {
     f_number_unsigned_t j = 0;
     pid_t pid = 0;
 
-    // A simple but inaccurate interval counter (expect this to be replaced in the future).
+    // A simple but inaccurate interval counter.
     const f_number_unsigned_t interval_nanoseconds = entry->timeout_exit < 1000 ? (entry->timeout_exit < 100 ? 5000000 : 100000000) : 500000000;
     const f_number_unsigned_t interval_milliseconds = entry->timeout_exit < 1000 ? (entry->timeout_exit < 100 ? 5 : 100) : 500;
 
     time.tv_sec = 0;
     time.tv_nsec = interval_nanoseconds;
 
-    if (main->process.mode == controller_process_mode_helper_e && main->program.parameters.array[controller_parameter_validate_e].result == f_console_result_none_e) {
-      int value = 0;
-      f_number_unsigned_t lapsed = 0;
-
+    if (main->process.mode == controller_process_mode_helper_e && !(main->setting.flag & controller_main_flag_validate_e)) {
       for (i = 0; i < main->thread.instances.used; ++i) {
 
         if (!main->thread.instances.array[i]) continue;
@@ -116,7 +113,7 @@ extern "C" {
       main->thread.id_signal = 0;
     }
 
-    if (main->process.mode == controller_process_mode_helper_e && main->program.parameters.array[controller_parameter_validate_e].result == f_console_result_none_e) {
+    if (main->process.mode == controller_process_mode_helper_e && !(main->setting.flag & controller_main_flag_validate_e)) {
       f_thread_mutex_unlock(&main->thread.lock.cancel);
 
       return;
@@ -170,7 +167,7 @@ extern "C" {
 
           while (instance->childs.array[j] > 0 && lapsed < entry->timeout_exit) {
 
-            // A hackish way to determine if the child instance exists while waiting.
+            // A hackish way to determine if the child instance exists while waiting (@todo look into pidfd() and epoll_wait()).
             if (getpgid(instance->childs.array[j]) >= 0) {
               time.tv_sec = 0;
               time.tv_nsec = interval_nanoseconds;
@@ -195,7 +192,7 @@ extern "C" {
             if (pid) {
               while (lapsed < entry->timeout_exit) {
 
-                // A hackish way to determine if the instance exists while waiting.
+                // A hackish way to determine if the instance exists while waiting (@todo look into pidfd() and epoll_wait()).
                 if (getpgid(pid) >= 0) {
                   time.tv_sec = 0;
                   time.tv_nsec = interval_nanoseconds;
@@ -255,7 +252,7 @@ extern "C" {
 
           if (instance->childs.array[j]) {
 
-            // A hackish way to determine if the child instance exists, and if it does then forcibly terminate it.
+            // A hackish way to determine if the child instance exists, and if it does then forcibly terminate it (@todo look into pidfd() and epoll_wait()).
             if (getpgid(instance->childs.array[j]) >= 0) {
               f_signal_send(F_signal_kill, instance->childs.array[j]);
             }
@@ -312,9 +309,7 @@ extern "C" {
 #ifndef _di_controller_thread_instance_exit_
   void controller_thread_instance_exit(controller_t * const main) {
 
-    if (!main) return;
-
-    if (main->thread.enabled != controller_thread_enabled_exit_e) return;
+    if (!main || main->thread.enabled != controller_thread_enabled_exit_e) return;
 
     if (main->process.ready == controller_process_ready_done_e) {