]> Kevux Git Server - controller/commitdiff
Regression: Handle print thread locking when printing errors.
authorKevin Day <Kevin@kevux.org>
Fri, 26 Jul 2024 00:31:05 +0000 (19:31 -0500)
committerKevin Day <Kevin@kevux.org>
Fri, 26 Jul 2024 00:31:05 +0000 (19:31 -0500)
sources/c/program/controller/main/print/error.c

index 7d8f620c76d475c95595f9e541c89fa8a0c00301..d5d4eef543d0956622b495a52c1f6d21f2a2b658 100644 (file)
@@ -12,8 +12,12 @@ extern "C" {
 
     controller_t * const main = (controller_t *) print->custom;
 
+    f_thread_mutex_lock(&main->thread.lock.print);
+
     fll_error_print(print, F_status_set_fine(main->setting.state.status), function, fll_error_file_flag_fallback_e);
 
+    f_thread_mutex_unlock(&main->thread.lock.print);
+
     return F_okay;
   }
 #endif // _di_controller_print_error_
@@ -44,8 +48,12 @@ extern "C" {
 
     controller_t * const main = (controller_t *) print->custom;
 
+    f_thread_mutex_lock(&main->thread.lock.print);
+
     fll_error_file_print(print, F_status_set_fine(main->setting.state.status), function, fll_error_file_flag_fallback_e, name, operation, type);
 
+    f_thread_mutex_unlock(&main->thread.lock.print);
+
     return F_okay;
   }
 #endif // _di_controller_print_error_file_
@@ -53,11 +61,17 @@ extern "C" {
 #ifndef _di_controller_print_error_file_status_
   f_status_t controller_print_error_file_status(fl_print_t * const print, const f_string_t function, const f_string_static_t name, const f_string_static_t operation, const uint8_t type, const f_status_t status) {
 
-    if (!print) return F_status_set_error(F_output_not);
+    if (!print || !print->custom) return F_status_set_error(F_output_not);
     if (print->verbosity == f_console_verbosity_quiet_e) return F_output_not;
 
+    controller_t * const main = (controller_t *) print->custom;
+
+    f_thread_mutex_lock(&main->thread.lock.print);
+
     fll_error_file_print(print, status, function, fll_error_file_flag_fallback_e, name, operation, type);
 
+    f_thread_mutex_unlock(&main->thread.lock.print);
+
     return F_okay;
   }
 #endif // _di_controller_print_error_file_status_
@@ -65,16 +79,18 @@ extern "C" {
 #ifndef _di_controller_print_error_file_pid_exists_
   f_status_t controller_print_error_file_pid_exists(fl_print_t * const print, controller_thread_t * const thread, const f_string_dynamic_t path) {
 
-    if (!print) return F_status_set_error(F_output_not);
+    if (!print || !print->custom) return F_status_set_error(F_output_not);
     if (print->verbosity < f_console_verbosity_error_e) return F_output_not;
 
-    controller_lock_print(print->to, 0);
+    controller_t * const main = (controller_t *) print->custom;
+
+    controller_lock_print(print->to, &main->thread);
 
     fl_print_format("%r%[%QThe pid file '%]", print->to, f_string_eol_s, print->context, print->prefix, print->context);
     fl_print_format(f_string_format_Q_single_s.string, print->to, print->set->notable, path, print->set->notable);
     fl_print_format("%[' must not already exist.%]%r", print->to, print->context, print->context, f_string_eol_s);
 
-    controller_unlock_print_flush(print->to, 0);
+    controller_unlock_print_flush(print->to, &main->thread);
 
     return F_okay;
   }
@@ -83,11 +99,17 @@ extern "C" {
 #ifndef _di_controller_print_error_status_
   f_status_t controller_print_error_status(fl_print_t * const print, const f_string_t function, const f_status_t status) {
 
-    if (!print) return F_status_set_error(F_output_not);
+    if (!print || !print->custom) return F_status_set_error(F_output_not);
     if (print->verbosity < f_console_verbosity_error_e) return F_output_not;
 
+    controller_t * const main = (controller_t *) print->custom;
+
+    f_thread_mutex_lock(&main->thread.lock.print);
+
     fll_error_print(print, status, function, fll_error_file_flag_fallback_e);
 
+    f_thread_mutex_unlock(&main->thread.lock.print);
+
     return F_okay;
   }
 #endif // _di_controller_print_error_status_