From 49a3d41d1c17734b0a8299b356f1e299386f4a42 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Mon, 8 Jul 2024 22:57:46 -0500 Subject: [PATCH] Bugfix: Don't assign enabled variable on lock failure to avoid potential race condition in the Controller program. --- level_3/controller/c/thread/private-thread_process.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/level_3/controller/c/thread/private-thread_process.c b/level_3/controller/c/thread/private-thread_process.c index 2720596..e11dae0 100644 --- a/level_3/controller/c/thread/private-thread_process.c +++ b/level_3/controller/c/thread/private-thread_process.c @@ -374,21 +374,13 @@ extern "C" { f_thread_mutex_unlock(&global->thread->lock.alert); } - else { - global->thread->enabled = controller_thread_enabled_not_e; - } } else { struct timespec time; do { status = f_thread_mutex_lock(&global->thread->lock.alert); - - if (F_status_is_error(status)) { - global->thread->enabled = controller_thread_enabled_not_e; - - break; - } + if (F_status_is_error(status)) break; controller_time(controller_thread_exit_ready_timeout_seconds_d, controller_thread_exit_ready_timeout_nanoseconds_d, &time); @@ -404,9 +396,6 @@ extern "C" { f_thread_mutex_unlock(&global->thread->lock.alert); } - else { - global->thread->enabled = controller_thread_enabled_not_e; - } } } @@ -426,9 +415,6 @@ extern "C" { f_thread_mutex_unlock(&global->thread->lock.alert); } - else { - global->thread->enabled = controller_thread_enabled_not_e; - } } } #endif // _di_controller_thread_process_exit_ -- 1.8.3.1