From: Kevin Day Date: Tue, 12 Aug 2025 02:51:13 +0000 (-0500) Subject: Update: Relocate the clean up thread thread cancel state. X-Git-Tag: 0.7.3~34 X-Git-Url: https://www.git.kevux.org/?a=commitdiff_plain;h=197111f01b5ef7a50c15db79eae9a56e7f1b5f13;p=controller 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. --- 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));