From 197111f01b5ef7a50c15db79eae9a56e7f1b5f13 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Mon, 11 Aug 2025 21:51:13 -0500 Subject: [PATCH] Update: Relocate the clean up thread thread cancel state. Relocate the cancel state changes to outside both waits. I do not like how this is now happening with a thread lock in place. I will need to do further research and possibly further changes to better handle this. For now, this is necessary so that when I send an interrupt signal that the clean up thread will cancel properly. --- sources/c/program/controller/main/thread/cleanup.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sources/c/program/controller/main/thread/cleanup.c b/sources/c/program/controller/main/thread/cleanup.c index f0d8400..8952112 100644 --- a/sources/c/program/controller/main/thread/cleanup.c +++ b/sources/c/program/controller/main/thread/cleanup.c @@ -22,6 +22,9 @@ extern "C" { while (controller_thread_enable_get(&main->thread) == controller_thread_enable_e) { + // Allow thread to be interrupted and auto-cancelled while sleeping. + f_thread_cancel_state_set(PTHREAD_CANCEL_ASYNCHRONOUS, 0); + controller_time_now( main->setting.flag & controller_main_flag_simulate_d ? controller_thread_cleanup_interval_short_d @@ -41,15 +44,12 @@ extern "C" { else { status = F_okay; - // Allow thread to be interrupted and auto-cancelled while sleeping. - f_thread_cancel_state_set(PTHREAD_CANCEL_ASYNCHRONOUS, 0); - f_time_sleep_spec(delay, 0); - - // Prevent thread from being interrupted and auto-cancelled. - f_thread_cancel_state_set(PTHREAD_CANCEL_DEFERRED, 0); } + // Prevent thread from being interrupted and auto-cancelled. + f_thread_cancel_state_set(PTHREAD_CANCEL_DEFERRED, 0); + // Reaping child processes is not critical, so don't care if the reap flag cannot be unset. if (!controller_thread_signal_get(&main->thread) && F_status_is_error_not(status)) { memset((void *) &signal_data, 0, sizeof(siginfo_t)); -- 1.8.3.1