From: Kevin Day Date: Sat, 15 Jun 2024 04:28:34 +0000 (-0500) Subject: Progress: Continue migrating the project. X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=f4af8361d353a96e6311251ea1b18960c877de5e;p=controller Progress: Continue migrating the project. --- diff --git a/sources/c/main/controller.h b/sources/c/main/controller.h index 47ef9ea..289b065 100644 --- a/sources/c/main/controller.h +++ b/sources/c/main/controller.h @@ -120,6 +120,7 @@ #include #include #include +#include #include #include #include diff --git a/sources/c/main/entry.c b/sources/c/main/entry.c index 2a6a5d4..153c59b 100644 --- a/sources/c/main/entry.c +++ b/sources/c/main/entry.c @@ -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); } diff --git a/sources/c/main/process.c b/sources/c/main/process.c index 3d46a91..b5bc2de 100644 --- a/sources/c/main/process.c +++ b/sources/c/main/process.c @@ -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; diff --git a/sources/c/main/rule/action.c b/sources/c/main/rule/action.c index 332b29d..566ad02 100644 --- a/sources/c/main/rule/action.c +++ b/sources/c/main/rule/action.c @@ -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; } diff --git a/sources/c/main/rule/item.c b/sources/c/main/rule/item.c index dbf29c7..32f9131 100644 --- a/sources/c/main/rule/item.c +++ b/sources/c/main/rule/item.c @@ -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)); diff --git a/sources/c/main/rule/setting.c b/sources/c/main/rule/setting.c index bb2dd58..f7a4017 100644 --- a/sources/c/main/rule/setting.c +++ b/sources/c/main/rule/setting.c @@ -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); } } diff --git a/sources/c/main/thread/instance.c b/sources/c/main/thread/instance.c index 53af640..8a3ab7c 100644 --- a/sources/c/main/thread/instance.c +++ b/sources/c/main/thread/instance.c @@ -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) {