]> Kevux Git Server - controller/commitdiff
Progress: Continue migrating the project, and do some restructuring.
authorKevin Day <Kevin@kevux.org>
Fri, 12 Jul 2024 03:27:43 +0000 (22:27 -0500)
committerKevin Day <Kevin@kevux.org>
Fri, 12 Jul 2024 03:30:45 +0000 (22:30 -0500)
Don't provide default examples as the settings.
Move all of these into an examples directory.
The examples directory is placed under a data directory that is intended to be for files such as those under the /usr/share directory.

This shows that the Featureless Make build settings specification is missing the "build_sources_data" which is a /usr/share equivalent of "-build_sources_setting" (aka /etc).

93 files changed:
data/build/settings
data/data/controller/example/cgroup/entries/chromium.entry [moved from data/settings/controller/example/cgroup_example/entries/chromium.entry with 100% similarity]
data/data/controller/example/cgroup/entries/eclipse.entry [moved from data/settings/controller/example/cgroup_example/entries/eclipse.entry with 100% similarity]
data/data/controller/example/cgroup/entries/firefox.entry [moved from data/settings/controller/example/cgroup_example/entries/firefox.entry with 100% similarity]
data/data/controller/example/cgroup/entries/setup_cgroups.entry [moved from data/settings/controller/example/cgroup_example/entries/setup_cgroups.entry with 100% similarity]
data/data/controller/example/cgroup/rules/program/chromium.rule [moved from data/settings/controller/example/cgroup_example/rules/program/chromium.rule with 100% similarity]
data/data/controller/example/cgroup/rules/program/eclipse.rule [moved from data/settings/controller/example/cgroup_example/rules/program/eclipse.rule with 100% similarity]
data/data/controller/example/cgroup/rules/program/firefox.rule [moved from data/settings/controller/example/cgroup_example/rules/program/firefox.rule with 100% similarity]
data/data/controller/example/cgroup/rules/setup/cgroups.rule [moved from data/settings/controller/example/cgroup_example/rules/setup/cgroups.rule with 100% similarity]
data/data/controller/example/init/entries/default.entry [moved from data/settings/controller/entries/default.entry with 100% similarity]
data/data/controller/example/init/entries/maintenance.entry [moved from data/settings/controller/entries/maintenance.entry with 100% similarity]
data/data/controller/example/init/rules/boot/devices.rule [moved from data/settings/controller/rules/boot/devices.rule with 100% similarity]
data/data/controller/example/init/rules/boot/file_system.rule [moved from data/settings/controller/rules/boot/file_system.rule with 100% similarity]
data/data/controller/example/init/rules/boot/modules.rule [moved from data/settings/controller/rules/boot/modules.rule with 100% similarity]
data/data/controller/example/init/rules/boot/proc.rule [moved from data/settings/controller/rules/boot/proc.rule with 100% similarity]
data/data/controller/example/init/rules/boot/root.rule [moved from data/settings/controller/rules/boot/root.rule with 100% similarity]
data/data/controller/example/init/rules/maintenance/console.rule [moved from data/settings/controller/rules/maintenance/console.rule with 100% similarity]
data/data/controller/example/init/rules/net/all.rule [moved from data/settings/controller/rules/net/all.rule with 100% similarity]
data/data/controller/example/init/rules/net/loopback.rule [moved from data/settings/controller/rules/net/loopback.rule with 100% similarity]
data/data/controller/example/init/rules/service/dbus.rule [moved from data/settings/controller/rules/service/dbus.rule with 100% similarity]
data/data/controller/example/init/rules/service/logger.rule [moved from data/settings/controller/rules/service/logger.rule with 100% similarity]
data/data/controller/example/init/rules/service/mouse.rule [moved from data/settings/controller/rules/service/mouse.rule with 100% similarity]
data/data/controller/example/init/rules/task/clock.rule [moved from data/settings/controller/rules/task/clock.rule with 100% similarity]
data/data/controller/example/init/rules/task/keyboard.rule [moved from data/settings/controller/rules/task/keyboard.rule with 100% similarity]
data/data/controller/example/init/rules/task/ntpdate.rule [moved from data/settings/controller/rules/task/ntpdate.rule with 100% similarity]
data/data/controller/example/init/rules/terminal/four.rule [moved from data/settings/controller/rules/terminal/four.rule with 100% similarity]
data/data/controller/example/init/rules/terminal/one.rule [moved from data/settings/controller/rules/terminal/one.rule with 100% similarity]
data/data/controller/example/init/rules/terminal/three.rule [moved from data/settings/controller/rules/terminal/three.rule with 100% similarity]
data/data/controller/example/init/rules/terminal/two.rule [moved from data/settings/controller/rules/terminal/two.rule with 100% similarity]
data/data/controller/example/miscellaneous/entries/asynchronous-serial.entry [moved from data/settings/controller/example/entries/asynchronous-serial.entry with 100% similarity]
data/data/controller/example/miscellaneous/entries/asynchronous.entry [moved from data/settings/controller/example/entries/asynchronous.entry with 100% similarity]
data/data/controller/example/miscellaneous/entries/delay-program.entry [moved from data/settings/controller/example/entries/delay-program.entry with 100% similarity]
data/data/controller/example/miscellaneous/entries/delay-service.entry [moved from data/settings/controller/example/entries/delay-service.entry with 100% similarity]
data/data/controller/example/miscellaneous/entries/environment.entry [moved from data/settings/controller/example/entries/environment.entry with 100% similarity]
data/data/controller/example/miscellaneous/entries/htop-alternate.entry [moved from data/settings/controller/example/entries/htop-alternate.entry with 100% similarity]
data/data/controller/example/miscellaneous/entries/htop-command.entry [moved from data/settings/controller/example/entries/htop-command.entry with 100% similarity]
data/data/controller/example/miscellaneous/entries/htop.entry [moved from data/settings/controller/example/entries/htop.entry with 100% similarity]
data/data/controller/example/miscellaneous/entries/iki.entry [moved from data/settings/controller/example/entries/iki.entry with 100% similarity]
data/data/controller/example/miscellaneous/entries/serial-alternate.entry [moved from data/settings/controller/example/entries/serial-alternate.entry with 100% similarity]
data/data/controller/example/miscellaneous/entries/serial.entry [moved from data/settings/controller/example/entries/serial.entry with 100% similarity]
data/data/controller/example/miscellaneous/entries/sshd.entry [moved from data/settings/controller/example/entries/sshd.entry with 100% similarity]
data/data/controller/example/miscellaneous/entries/test.entry [moved from data/settings/controller/example/entries/test.entry with 100% similarity]
data/data/controller/example/miscellaneous/entries/up.entry [moved from data/settings/controller/example/entries/up.entry with 100% similarity]
data/data/controller/example/miscellaneous/entries/utility.entry [moved from data/settings/controller/example/entries/utility.entry with 100% similarity]
data/data/controller/example/miscellaneous/exits/htop-alternate.exit [moved from data/settings/controller/example/exits/htop-alternate.exit with 100% similarity]
data/data/controller/example/miscellaneous/exits/serial.exit [moved from data/settings/controller/example/exits/serial.exit with 100% similarity]
data/data/controller/example/miscellaneous/exits/sshd.exit [moved from data/settings/controller/example/exits/sshd.exit with 100% similarity]
data/data/controller/example/miscellaneous/rules/asynchronous/sleep_1.rule [moved from data/settings/controller/example/rules/asynchronous/sleep_1.rule with 100% similarity]
data/data/controller/example/miscellaneous/rules/asynchronous/sleep_10.rule [moved from data/settings/controller/example/rules/asynchronous/sleep_10.rule with 100% similarity]
data/data/controller/example/miscellaneous/rules/asynchronous/sleep_2.rule [moved from data/settings/controller/example/rules/asynchronous/sleep_2.rule with 100% similarity]
data/data/controller/example/miscellaneous/rules/asynchronous/sleep_3.rule [moved from data/settings/controller/example/rules/asynchronous/sleep_3.rule with 100% similarity]
data/data/controller/example/miscellaneous/rules/asynchronous/sleep_5.rule [moved from data/settings/controller/example/rules/asynchronous/sleep_5.rule with 100% similarity]
data/data/controller/example/miscellaneous/rules/asynchronous/sleep_8.rule [moved from data/settings/controller/example/rules/asynchronous/sleep_8.rule with 100% similarity]
data/data/controller/example/miscellaneous/rules/command/htop.rule [moved from data/settings/controller/example/rules/command/htop.rule with 100% similarity]
data/data/controller/example/miscellaneous/rules/command/multiple.rule [moved from data/settings/controller/example/rules/command/multiple.rule with 100% similarity]
data/data/controller/example/miscellaneous/rules/delay/long.rule [moved from data/settings/controller/example/rules/delay/long.rule with 100% similarity]
data/data/controller/example/miscellaneous/rules/delay/short.rule [moved from data/settings/controller/example/rules/delay/short.rule with 100% similarity]
data/data/controller/example/miscellaneous/rules/environment/default.rule [moved from data/settings/controller/example/rules/environment/default.rule with 100% similarity]
data/data/controller/example/miscellaneous/rules/environment/empty.rule [moved from data/settings/controller/example/rules/environment/empty.rule with 100% similarity]
data/data/controller/example/miscellaneous/rules/environment/exported.rule [moved from data/settings/controller/example/rules/environment/exported.rule with 100% similarity]
data/data/controller/example/miscellaneous/rules/environment/exporting.rule [moved from data/settings/controller/example/rules/environment/exporting.rule with 100% similarity]
data/data/controller/example/miscellaneous/rules/environment/fake-nothing.rule [moved from data/settings/controller/example/rules/environment/fake-nothing.rule with 100% similarity]
data/data/controller/example/miscellaneous/rules/environment/fake-something.rule [moved from data/settings/controller/example/rules/environment/fake-something.rule with 100% similarity]
data/data/controller/example/miscellaneous/rules/maintenance/boom.rule [moved from data/settings/controller/example/rules/maintenance/boom.rule with 100% similarity]
data/data/controller/example/miscellaneous/rules/print/newline.rule [moved from data/settings/controller/example/rules/print/newline.rule with 100% similarity]
data/data/controller/example/miscellaneous/rules/script/create_socket_path.rule [moved from data/settings/controller/example/rules/script/create_socket_path.rule with 100% similarity]
data/data/controller/example/miscellaneous/rules/script/fail.rule [moved from data/settings/controller/example/rules/script/fail.rule with 100% similarity]
data/data/controller/example/miscellaneous/rules/script/iki.rule [moved from data/settings/controller/example/rules/script/iki.rule with 100% similarity]
data/data/controller/example/miscellaneous/rules/script/php.rule [moved from data/settings/controller/example/rules/script/php.rule with 100% similarity]
data/data/controller/example/miscellaneous/rules/script/python.rule [moved from data/settings/controller/example/rules/script/python.rule with 100% similarity]
data/data/controller/example/miscellaneous/rules/script/require_me.rule [moved from data/settings/controller/example/rules/script/require_me.rule with 100% similarity]
data/data/controller/example/miscellaneous/rules/script/succeed.rule [moved from data/settings/controller/example/rules/script/succeed.rule with 100% similarity]
data/data/controller/example/miscellaneous/rules/serial/s_1.rule [moved from data/settings/controller/example/rules/serial/s_1.rule with 100% similarity]
data/data/controller/example/miscellaneous/rules/serial/s_2.rule [moved from data/settings/controller/example/rules/serial/s_2.rule with 100% similarity]
data/data/controller/example/miscellaneous/rules/serial/s_3.rule [moved from data/settings/controller/example/rules/serial/s_3.rule with 100% similarity]
data/data/controller/example/miscellaneous/rules/serial/s_4.rule [moved from data/settings/controller/example/rules/serial/s_4.rule with 100% similarity]
data/data/controller/example/miscellaneous/rules/serial/s_5.rule [moved from data/settings/controller/example/rules/serial/s_5.rule with 100% similarity]
data/data/controller/example/miscellaneous/rules/serial/s_6.rule [moved from data/settings/controller/example/rules/serial/s_6.rule with 100% similarity]
data/data/controller/example/miscellaneous/rules/service/sshd.rule [moved from data/settings/controller/example/rules/service/sshd.rule with 100% similarity]
data/data/controller/example/miscellaneous/rules/utility/sleeper_1.rule [moved from data/settings/controller/example/rules/utility/sleeper_1.rule with 100% similarity]
data/data/controller/example/miscellaneous/rules/utility/sleeper_2.rule [moved from data/settings/controller/example/rules/utility/sleeper_2.rule with 100% similarity]
data/data/controller/example/miscellaneous/rules/utility/sleeper_3.rule [moved from data/settings/controller/example/rules/utility/sleeper_3.rule with 100% similarity]
sources/c/main/controller.h
sources/c/main/print/debug/rule/action.h
sources/c/main/print/debug/rule/execute.h
sources/c/main/print/debug/rule/instance.c [new file with mode: 0644]
sources/c/main/print/debug/rule/instance.h [new file with mode: 0644]
sources/c/main/print/error/rule/instance.c [new file with mode: 0644]
sources/c/main/print/error/rule/instance.h [new file with mode: 0644]
sources/c/main/rule/execute.c
sources/c/main/rule/execute.h
sources/c/main/rule/instance.c
sources/c/main/rule/instance.h

index 4d81f0f37d3e71833023cbd85f5f0a853091ffe6..b5c1f441d35c371325d50647e0a4914be0b039a8 100644 (file)
@@ -49,11 +49,11 @@ build_sources_library file.c lock.c path.c process.c
 build_sources_library rule.c rule/action.c rule/execute.c rule/expand.c rule/instance.c rule/is.c rule/item.c rule/parameter.c rule/read.c rule/setting.c rule/wait.c
 build_sources_library perform.c
 build_sources_library print/data.c
-build_sources_library print/debug.c print/debug/rule/action.c print/debug/rule/execute.c print/debug/perform/control.c print/debug/perform/pid.c
+build_sources_library print/debug.c print/debug/rule/action.c print/debug/rule/execute.c print/debug/rule/instance.c print/debug/perform/control.c print/debug/perform/pid.c
 build_sources_library print/error.c
 build_sources_library print/error/entry.c print/error/entry/action.c print/error/entry/item.c print/error/entry/setting.c
 build_sources_library print/error/perform/pid.c
-build_sources_library print/error/rule.c print/error/rule/action.c print/error/rule/item.c print/error/rule/setting.c
+build_sources_library print/error/rule.c print/error/rule/action.c print/error/rule/instance.c print/error/rule/item.c print/error/rule/setting.c
 build_sources_library print/lock.c print/error/lock.c
 build_sources_library print/output/entry/setting.c print/output/rule/execute.c print/output/rule/setting.c print/output/rule/validate.c
 build_sources_library print/message.c print/message/entry.c print/message/entry/action.c print/message/entry/item.c
@@ -74,11 +74,11 @@ build_sources_headers file.h lock.h path.h process.h
 build_sources_headers rule.h rule/action.h rule/execute.h rule/expand.h rule/instance.h rule/is.h rule/item.h rule/parameter.h rule/read.h rule/setting.h rule/wait.h
 build_sources_headers perform.h
 build_sources_headers print/data.h
-build_sources_headers print/debug.h print/debug/rule/action.h print/debug/rule/execute.h print/debug/perform/control.h print/debug/perform/pid.h
+build_sources_headers print/debug.h print/debug/rule/action.h print/debug/rule/execute.h print/debug/rule/instance.h print/debug/perform/control.h print/debug/perform/pid.h
 build_sources_headers print/error.h
 build_sources_headers print/error/entry.h print/error/entry/action.h print/error/entry/item.h print/error/entry/setting.h
 build_sources_headers print/error/perform/pid.h
-build_sources_headers print/error/rule.h print/error/rule/action.h print/error/rule/item.h print/error/rule/setting.h
+build_sources_headers print/error/rule.h print/error/rule/action.h print/error/rule/instance.h print/error/rule/item.h print/error/rule/setting.h
 build_sources_headers print/lock.h print/error/lock.h
 build_sources_headers print/output/entry/setting.h print/output/rule/execute.h print/output/rule/setting.h print/output/rule/validate.h
 build_sources_headers print/message.h print/message/entry.h print/message/entry/action.h print/message/entry/item.h
@@ -90,8 +90,6 @@ build_sources_headers validate.h
 
 build_sources_documentation man
 
-build_sources_setting controller
-
 build_script yes
 build_shared yes
 build_static no
index 9f3ac712745aba3a351b921246a07c3e3601df03..848db826c7e9a7bf9c80f1dabc3aca3f7a11ace3 100644 (file)
 #include <program/controller/main/print/debug/perform/pid.h>
 #include <program/controller/main/print/debug/rule/action.h>
 #include <program/controller/main/print/debug/rule/execute.h>
+#include <program/controller/main/print/debug/rule/instance.h>
 #include <program/controller/main/print/error.h>
 #include <program/controller/main/print/error/entry.h>
 #include <program/controller/main/print/error/entry/action.h>
 #include <program/controller/main/print/error/perform/pid.h>
 #include <program/controller/main/print/error/rule.h>
 #include <program/controller/main/print/error/rule/action.h>
+#include <program/controller/main/print/error/rule/instance.h>
 #include <program/controller/main/print/error/rule/item.h>
 #include <program/controller/main/print/error/rule/setting.h>
 #include <program/controller/main/print/lock.h>
index 73db9a64c753df34c59fed46c4b24ff6f56b6a67..8d07879fc85ad15975fb841bffe47009c3a8479d 100644 (file)
@@ -5,12 +5,12 @@
  * API Version: 0.7
  * Licenses: lgpl-2.1-or-later
  *
- * Provides the print Entry Action debug functionality.
+ * Provides the print Entry Rule Action debug functionality.
  *
  * This is auto-included and should not need to be explicitly included.
  */
-#ifndef _controller_main_print_debug_entry_action_h
-#define _controller_main_print_debug_entry_action_h
+#ifndef _controller_main_print_debug_rule_action_h
+#define _controller_main_print_debug_rule_action_h
 
 #ifdef __cplusplus
 extern "C" {
@@ -46,4 +46,4 @@ extern "C" {
 } // extern "C"
 #endif
 
-#endif // _controller_main_print_debug_entry_action_h
+#endif // _controller_main_print_debug_rule_action_h
index 94f2bac5908172931e5c819592c1c2bc126f2d2f..c9b4346250b32194edf4adab3784cf8faa2286ba 100644 (file)
@@ -5,7 +5,7 @@
  * API Version: 0.7
  * Licenses: lgpl-2.1-or-later
  *
- * Provides the print Entry Action debug functionality.
+ * Provides the print Entry Rule execute debug functionality.
  *
  * This is auto-included and should not need to be explicitly included.
  */
diff --git a/sources/c/main/print/debug/rule/instance.c b/sources/c/main/print/debug/rule/instance.c
new file mode 100644 (file)
index 0000000..3714a9c
--- /dev/null
@@ -0,0 +1,29 @@
+#include "../../../controller.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _di_controller_print_debug_rule_instance_need_want_wish_
+  f_status_t controller_print_debug_rule_instance_need_want_wish(fl_print_t * const print, controller_instance_t * const instance, const f_string_static_t need_want_wish, const f_string_static_t value, const f_string_t why) {
+
+    if (!print || !print->custom || !instance) return F_status_set_error(F_output_not);
+    if (print->verbosity < f_console_verbosity_debug_e) return F_output_not;
+
+    controller_t * const main = (controller_t *) print->custom;
+
+    controller_lock_print(print->to, &main->thread);
+
+    controller_print_error_rule_item_need_want_wish(print, need_want_wish, value, why);
+
+    controller_print_error_rule_cache(print, &instance->cache.action, F_true);
+
+    controller_unlock_print_flush(print->to, &main->thread);
+
+    return F_okay;
+  }
+#endif // _di_controller_print_debug_rule_instance_need_want_wish_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
diff --git a/sources/c/main/print/debug/rule/instance.h b/sources/c/main/print/debug/rule/instance.h
new file mode 100644 (file)
index 0000000..6a0f3ed
--- /dev/null
@@ -0,0 +1,56 @@
+/**
+ * FLL - Level 3
+ *
+ * Project: Controller
+ * API Version: 0.7
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Provides the print Entry Rule Instance debug functionality.
+ *
+ * This is auto-included and should not need to be explicitly included.
+ */
+#ifndef _controller_main_print_debug_rule_instance_h
+#define _controller_main_print_debug_rule_instance_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Print a warning message related to need/want/wish settings of some Rule for some Instance.
+ *
+ * @param print
+ *   The output structure to print to.
+ *
+ *   This requires print.custom to be controller_t.
+ *
+ *   This does not alter print.custom.setting.state.status.
+ *
+ *   Must not be NULL.
+ * @param instance
+ *   The Controller Instance.
+ *
+ *   Must not be NULL.
+ * @param need_want_wish
+ *   The appropriate string, such as "needs", "wants", or "wishes for" to output when describing this error/warning.
+ *   This string is expected to already be "safe" (no control characters, etc..).
+ * @param value
+ *   The value that is the error or warning.
+ * @param why
+ *   A short explanation on why this is an error or warning.
+ *
+ * @return
+ *   F_okay on success.
+ *   F_output_not on success, but no printing is performed.
+ *
+ *   F_output_not (with error bit) if setting is NULL.
+ */
+#ifndef _di_controller_print_debug_rule_instance_need_want_wish_
+  extern f_status_t controller_print_debug_rule_instance_need_want_wish(fl_print_t * const print, controller_instance_t * const instance, const f_string_static_t need_want_wish, const f_string_static_t value, const f_string_t why);
+#endif // #ifndef _di_controller_print_debug_rule_instance_need_want_wish_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _controller_main_print_debug_rule_instance_h
diff --git a/sources/c/main/print/error/rule/instance.c b/sources/c/main/print/error/rule/instance.c
new file mode 100644 (file)
index 0000000..b49eac4
--- /dev/null
@@ -0,0 +1,29 @@
+#include "../../../controller.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _di_controller_print_error_rule_instance_need_want_wish_
+  f_status_t controller_print_error_rule_instance_need_want_wish(fl_print_t * const print, controller_instance_t * const instance, const f_string_static_t need_want_wish, const f_string_static_t value, const f_string_t why) {
+
+    if (!print || !print->custom || !instance) return F_status_set_error(F_output_not);
+    if (print->verbosity < f_console_verbosity_debug_e) return F_output_not;
+
+    controller_t * const main = (controller_t *) print->custom;
+
+    controller_lock_print(print->to, &main->thread);
+
+    controller_print_error_rule_item_need_want_wish(print, need_want_wish, value, why);
+
+    controller_print_error_rule_cache(print, &instance->cache.action, F_true);
+
+    controller_unlock_print_flush(print->to, &main->thread);
+
+    return F_okay;
+  }
+#endif // _di_controller_print_error_rule_instance_need_want_wish_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
diff --git a/sources/c/main/print/error/rule/instance.h b/sources/c/main/print/error/rule/instance.h
new file mode 100644 (file)
index 0000000..bb792e4
--- /dev/null
@@ -0,0 +1,56 @@
+/**
+ * FLL - Level 3
+ *
+ * Project: Controller
+ * API Version: 0.7
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Provides the print Entry Rule Instance error functionality.
+ *
+ * This is auto-included and should not need to be explicitly included.
+ */
+#ifndef _controller_main_print_error_rule_instance_h
+#define _controller_main_print_error_rule_instance_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Print a error message related to need/want/wish settings of some Rule for some Instance.
+ *
+ * @param print
+ *   The output structure to print to.
+ *
+ *   This requires print.custom to be controller_t.
+ *
+ *   This does not alter print.custom.setting.state.status.
+ *
+ *   Must not be NULL.
+ * @param instance
+ *   The Controller Instance.
+ *
+ *   Must not be NULL.
+ * @param need_want_wish
+ *   The appropriate string, such as "needs", "wants", or "wishes for" to output when describing this error/warning.
+ *   This string is expected to already be "safe" (no control characters, etc..).
+ * @param value
+ *   The value that is the error or warning.
+ * @param why
+ *   A short explanation on why this is an error or warning.
+ *
+ * @return
+ *   F_okay on success.
+ *   F_output_not on success, but no printing is performed.
+ *
+ *   F_output_not (with error bit) if setting is NULL.
+ */
+#ifndef _di_controller_print_error_rule_instance_need_want_wish_
+  extern f_status_t controller_print_error_rule_instance_need_want_wish(fl_print_t * const print, controller_instance_t * const instance, const f_string_static_t need_want_wish, const f_string_static_t value, const f_string_t why);
+#endif // _di_controller_print_error_rule_instance_need_want_wish_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _controller_main_print_error_rule_instance_h
index d7598be32f24a2ea5ed41673b354708c6cefe0d5..c179053811387929b3f2a6dfe67b69ef89882d11 100644 (file)
@@ -5,7 +5,7 @@ extern "C" {
 #endif
 
 #ifndef _di_controller_rule_execute_
-  f_status_t controller_rule_execute(controller_t * const main, const uint8_t action, const uint8_t options, controller_instance_t * const instance) {
+  f_status_t controller_rule_execute(controller_t * const main, controller_instance_t * const instance, const uint8_t action, const uint8_t options) {
 
     if (!main || !instance) return F_status_set_error(F_parameter);
 
@@ -247,14 +247,14 @@ extern "C" {
           }
 
           do {
-            status = controller_rule_execute_foreground(instance->rule.items.array[i].type, f_string_empty_s, instance->cache.expanded, options, &execute_set, instance);
+            status = controller_rule_execute_foreground(instance, instance->rule.items.array[i].type, f_string_empty_s, instance->cache.expanded, options, &execute_set);
 
-            if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock) break;
+            if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock || F_status_set_fine(status) == F_lock_read) break;
             if (F_status_is_error(status) && F_status_set_fine(status) != F_failure) break;
 
           } while (controller_rule_execute_rerun(instance, &instance->rule.items.array[i], controller_rule_action_type_to_action_execute_type(action)) > 0);
 
-          if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock) break;
+          if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock || F_status_set_fine(status) == F_lock_read) break;
 
           if (F_status_is_error(status)) {
             instance->rule.items.array[i].actions.array[j].status = F_status_set_error(F_failure);
@@ -285,18 +285,18 @@ extern "C" {
 
           do {
             if (instance->rule.engine.used) {
-              status = controller_rule_execute_foreground(instance->rule.items.array[i].type, instance->rule.engine, instance->rule.engine_arguments, options, &execute_set, instance);
+              status = controller_rule_execute_foreground(instance, instance->rule.items.array[i].type, instance->rule.engine, instance->rule.engine_arguments, options, &execute_set);
             }
             else {
-              status = controller_rule_execute_foreground(instance->rule.items.array[i].type, controller_default_engine_s, instance->rule.engine_arguments, options, &execute_set, instance);
+              status = controller_rule_execute_foreground(instance, instance->rule.items.array[i].type, controller_default_engine_s, instance->rule.engine_arguments, options, &execute_set);
             }
 
-            if (status == F_child || F_status_set_fine(status) == F_lock) break;
+            if (status == F_child || F_status_set_fine(status) == F_lock || F_status_set_fine(status) == F_lock_read) break;
             if (F_status_is_error(status) && F_status_set_fine(status) != F_failure) break;
 
           } while (controller_rule_execute_rerun(instance, &instance->rule.items.array[i], controller_rule_action_type_to_action_execute_type(action)) > 0);
 
-          if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock) break;
+          if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock || F_status_set_fine(status) == F_lock_read) break;
 
           if (F_status_is_error(status)) {
             instance->rule.items.array[i].actions.array[j].status = F_status_set_error(F_failure);
@@ -322,12 +322,12 @@ extern "C" {
             do {
               status = controller_rule_execute_pid_with(instance, instance->rule.items.array[i].pid_file, instance->rule.items.array[i].type, f_string_empty_s, instance->cache.expanded, options, instance->rule.items.array[i].with, &execute_set);
 
-              if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock) break;
+              if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock || F_status_set_fine(status) == F_lock_read) break;
               if (F_status_is_error(status) && F_status_set_fine(status) != F_failure) break;
 
             } while (controller_rule_execute_rerun(instance, &instance->rule.items.array[i], controller_rule_action_type_to_action_execute_type(action)) > 0);
 
-            if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock) break;
+            if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock || F_status_set_fine(status) == F_lock_read) break;
 
             if (F_status_is_error(status)) {
               instance->rule.items.array[i].actions.array[j].status = F_status_set_error(F_failure);
@@ -366,12 +366,12 @@ extern "C" {
             do {
               status = controller_rule_execute_pid_with(instance, instance->rule.items.array[i].pid_file, instance->rule.items.array[i].type, instance->rule.engine.used ? instance->rule.engine : controller_default_engine_s, instance->rule.engine_arguments, options, instance->rule.items.array[i].with, &execute_set);
 
-              if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock) break;
+              if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock || F_status_set_fine(status) == F_lock_read) break;
               if (F_status_is_error(status) && F_status_set_fine(status) != F_failure) break;
 
             } while (controller_rule_execute_rerun(instance, &instance->rule.items.array[i], controller_rule_action_type_to_action_execute_type(action)) > 0);
 
-            if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock) break;
+            if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock || F_status_set_fine(status) == F_lock_read) break;
 
             if (F_status_is_error(status)) {
               instance->rule.items.array[i].actions.array[j].status = F_status_set_error(F_failure);
@@ -406,11 +406,15 @@ extern "C" {
     } // for
 
     // Lock failed, attempt to re-establish lock before returning.
-    if (F_status_set_fine(status) == F_lock) {
-      status = controller_lock_read(instance->type != controller_instance_type_exit_e, F_true, &main->thread, &instance->lock);
-      if (F_status_is_error(status)) return F_status_set_error(F_lock);
-
+    if (F_status_set_fine(status) == F_lock || F_status_set_fine(status) == F_lock_read) {
       success = F_false;
+
+      if (F_status_set_fine(status) == F_lock_read) {
+        status = controller_lock_read(instance->type != controller_instance_type_exit_e, F_false, &main->thread, &instance->lock);
+        if (F_status_is_error(status)) return F_status_set_error(F_lock_read);
+
+        status = F_status_set_error(F_lock);
+      }
     }
 
     if (success == false && !instance->rule.items.used) {
@@ -427,7 +431,7 @@ extern "C" {
 #endif // _di_controller_rule_execute_
 
 #ifndef _di_controller_rule_execute_foreground_
-  f_status_t controller_rule_execute_foreground(const uint8_t type, const f_string_static_t program, const f_string_statics_t arguments, const uint8_t options, controller_execute_set_t * const execute_set, controller_instance_t * const instance) {
+  f_status_t controller_rule_execute_foreground(controller_instance_t * const instance, const uint8_t type, const f_string_static_t program, const f_string_statics_t arguments, const uint8_t options, controller_execute_set_t * const execute_set) {
 
     if (!instance || !instance->main) return F_status_set_error(F_parameter);
 
@@ -488,7 +492,7 @@ extern "C" {
         status_lock = controller_lock_read(instance->type != controller_instance_type_exit_e, F_false, &instance->main->thread, &instance->lock);
         if (F_status_is_error(status_lock)) return F_status_set_error(F_lock_read);
 
-        return F_status_set_error(F_lock_write);
+        return F_status_set_error(F_lock);
       }
 
       instance->result = result.status;
@@ -504,7 +508,7 @@ extern "C" {
 
         // Try again, after the first interrupt.
         if (F_status_set_fine(status_lock) == F_interrupt) {
-          status_lock = controller_lock_read_instance(instance, &instance->lock);
+          status_lock = controller_lock_read(instance->type != controller_instance_type_exit_e, F_false, &instance->main->thread, &instance->lock);
         }
 
         if (F_status_is_error(status_lock)) {
@@ -514,12 +518,7 @@ extern "C" {
         }
       }
 
-      if (WIFEXITED(result.status) ? WEXITSTATUS(result.status) : 0) {
-        status = F_status_set_error(F_failure);
-      }
-      else {
-        status = F_okay;
-      }
+      status = WIFEXITED(result.status) && WEXITSTATUS(result.status) ? F_status_set_error(F_failure) : F_okay;
     }
     else {
       main->program.child = result.status;
@@ -689,7 +688,7 @@ extern "C" {
         status_lock = controller_lock_read(instance->type != controller_instance_type_exit_e, F_false, &instance->main->thread, &instance->lock);
         if (F_status_is_error(status_lock)) return F_status_set_error(F_lock_read);
 
-        return F_status_set_error(F_lock_write);
+        return F_status_set_error(F_lock);
       }
 
       // Assign the child instance id to allow for the cancel instance to send appropriate termination signals to the child instance.
@@ -714,7 +713,7 @@ extern "C" {
         status_lock = controller_lock_read(instance->type != controller_instance_type_exit_e, F_false, &instance->main->thread, &instance->lock);
         if (F_status_is_error(status_lock)) return F_status_set_error(F_lock_read);
 
-        return F_status_set_error(F_lock_write);
+        return F_status_set_error(F_lock);
       }
 
       instance->result = result.status;
@@ -732,12 +731,7 @@ extern "C" {
         return F_status_set_error(F_lock);
       }
 
-      if (WIFEXITED(result.status) ? WEXITSTATUS(result.status) : 0) {
-        status = F_status_set_error(F_failure);
-      }
-      else {
-        status = F_okay;
-      }
+      status = WIFEXITED(result.status) && WEXITSTATUS(result.status) ? F_status_set_error(F_failure) : F_okay;
     }
     else {
       main->program.child = result.status;
@@ -780,7 +774,7 @@ extern "C" {
 
     if (!instance || !instance->main || !item) return F_false;
 
-    const int result = WIFEXITED(instance->result) ? WEXITSTATUS(instance->result) : 0;
+    const int result = WIFEXITED(instance->result) && WEXITSTATUS(instance->result);
 
     if (item->reruns[action].is & (result ? controller_rule_rerun_is_failure_d : controller_rule_rerun_is_success_d)) {
       controller_t * const main = instance->main;
index 6648e20df645ecf9617635ae06672b47c0a6723b..afb25702f893b3b3025dcb391100dfa12e85bc1e 100644 (file)
@@ -19,7 +19,7 @@ extern "C" {
 /**
  * Perform an execution of the given Rule.
  *
- * This requires that a read lock be set on process->lock before being called.
+ * This requires that a read lock be set on instance->lock before being called.
  *
  * @param main
  *   The main program data.
@@ -27,6 +27,10 @@ extern "C" {
  *   Must not be NULL.
  *
  *   This does not alter main.setting.state.status.
+ * @param instance
+ *   The instance data.
+ *
+ *   Must not be NULL.
  * @param action
  *   The Action to perform based on the Action type codes.
  *
@@ -41,10 +45,6 @@ extern "C" {
  * @param options
  *   Process options to consider when executing.
  *   If bit controller_instance_option_simulate_e, then the Rule execution is in simulation mode (printing a message that the Rule would be executed but does not execute the rule).
- * @param instance
- *   The instance data.
- *
- *   Must not be NULL.
  *
  * @return
  *   F_okay on success.
@@ -53,21 +53,26 @@ extern "C" {
  *
  *   F_failure (with error bit) if failed to execute.
  *   F_interrupt (with error bit) on receiving a process signal, such as an interrupt signal.
- *   F_lock (with error bit) if failed to re-establish read lock on process->lock while returning.
+ *   F_lock (with error bit) if failed to establish a lock, and the instance->lock read lock is already restored.
+ *   F_lock_read (with error bit) if failed to re-establish read lock on instance->lock while returning.
  *
  *   On success and the Rule is run synchronously, then the individual status for the Rule is set to F_complete.
  *   On success and the Rule is run asynchronously, then the individual status for the Rule is set to F_busy.
  *   On failure, the individual status for the Rule is set to an appropriate error status.
  */
 #ifndef _di_controller_rule_execute_
-  extern f_status_t controller_rule_execute(controller_t * const main, const uint8_t action, const uint8_t options, controller_instance_t * const instance);
+  extern f_status_t controller_rule_execute(controller_t * const main, controller_instance_t * const instance, const uint8_t action, const uint8_t options);
 #endif // _di_controller_rule_execute_
 
 /**
  * Perform an execution of the given Rule in the foreground.
  *
- * This requires that a read lock be set on process->lock before being called.
+ * This requires that a read lock be set on instance->lock before being called.
+ *
+ * @param instance
+ *   The instance data.
  *
+ *   Must not be NULL.
  * @param type
  *   The item type code.
  * @param program
@@ -81,25 +86,21 @@ extern "C" {
  *   The execute parameter and as settings.
  *
  *   Must not be NULL.
- * @param instance
- *   The instance data.
- *
- *   Must not be NULL.
  *
  * @return
  *   F_okay on success.
  *   F_child on child process exiting.
  *
  *   F_interrupt (with error bit) on receiving a process signal, such as an interrupt signal.
- *   F_lock_read (with error bit) if failed to re-establish read lock on process->lock while returning.
- *   F_lock_write (with error bit) if failed to establish write lock on process->lock, and the read lock is able to be restored.
+ *   F_lock (with error bit) if failed to establish a lock, and the instance->lock read lock is already restored.
+ *   F_lock_read (with error bit) if failed to re-establish read lock on instance->lock while returning.
  *
  *   Errors (with error bit) from: fll_execute_program().
  *
  * @see fll_execute_program()
  */
 #ifndef _di_controller_rule_execute_foreground_
-  extern f_status_t controller_rule_execute_foreground(const uint8_t type, const f_string_static_t program, const f_string_statics_t arguments, const uint8_t options, controller_execute_set_t * const execute_set, controller_instance_t * const instance);
+  extern f_status_t controller_rule_execute_foreground(controller_instance_t * const instance, const uint8_t type, const f_string_static_t program, const f_string_statics_t arguments, const uint8_t options, controller_execute_set_t * const execute_set);
 #endif // _di_controller_rule_execute_foreground_
 
 /**
@@ -143,11 +144,15 @@ extern "C" {
 /**
  * Perform an execution of the given Rule in the foreground or background and creating a PID file.
  *
- * This requires that a read lock be set on process->lock before being called.
+ * This requires that a read lock be set on instance->lock before being called.
  *
  * When this is synchronous, this will wait for the PID file to be generated before continuing.
  * When this is asynchronous, this will continue on adding the Rule id and Action to the asynchronous list.
  *
+ * @param instance
+ *   The instance data.
+ *
+ *   Must not be NULL.
  * @param pid_file
  *   The path to the PID file.
  * @param type
@@ -165,10 +170,6 @@ extern "C" {
  *   The execute parameter and as settings.
  *
  *   Must not be NULL.
- * @param instance
- *   The instance data.
- *
- *   Must not be NULL.
  *
  * @return
  *   F_okay on success.
@@ -176,8 +177,8 @@ extern "C" {
  *
  *   F_file_found (with error bit) if the PID file already exists.
  *   F_interrupt (with error bit) on receiving a process signal, such as an interrupt signal.
- *   F_lock_read (with error bit) if failed to re-establish read lock on process->lock while returning.
- *   F_lock_write (with error bit) if failed to establish write lock on process->lock, and the read lock is able to be restored.
+ *   F_lock (with error bit) if failed to establish a lock, and the instance->lock read lock is already restored.
+ *   F_lock_read (with error bit) if failed to re-establish read lock on instance->lock while returning.
  *
  *   Errors (with error bit) from: fll_execute_program().
  *
index e0b805d8316ffc8c34b7899956ce5c1b94e0be16..af28dc60323aa2dbed0892d688d9e547e68e0759 100644 (file)
@@ -97,10 +97,9 @@ extern "C" {
       f_number_unsigned_t id_rule = 0;
       f_number_unsigned_t id_dependency = 0;
 
-      bool found = F_false;
-
       controller_instance_t *dependency = 0;
 
+      uint8_t found = F_false;
       uint8_t options_instance = 0;
 
       const f_string_static_t strings[3] = {
@@ -113,7 +112,6 @@ extern "C" {
       f_string_dynamics_t *dynamics[3] = { &empty, &empty, &empty };
 
       if (instance->action) {
-
         for (i = 0; i < instance->rule.ons.used; ++i) {
 
           if (instance->rule.ons.array[i].action == instance->action) {
@@ -154,12 +152,7 @@ extern "C" {
               return status;
             }
 
-            status = F_true;
-          }
-
-          if (status == F_true) {
-            found = F_true;
-
+            status = found = F_true;
             dependency = main->thread.instances.array[id_dependency];
 
             status_lock = controller_lock_read_instance(instance, &dependency->active);
@@ -189,24 +182,19 @@ extern "C" {
               }
             }
           }
-          else {
-            f_thread_unlock(&main->thread.lock.instance);
-          }
 
           if (status != F_true) {
             found = F_false;
             id_rule = 0;
 
-            if (i == 0) {
-              controller_lock_print(main->program.error.to, &main->thread);
-
-              controller_print_error_rule_item_need_want_wish(&main->program.error, strings[i], dynamics[i]->array[j], "is not found");
-              controller_print_error_rule_cache(&main->program.error, &instance->cache.action, F_true);
-
-              controller_unlock_print_flush(main->program.error.to, &main->thread);
-
+            if (i) {
+              controller_print_debug_rule_instance_need_want_wish(&main->program.warning, instance, strings[i], dynamics[i]->array[j], "is not found");
+            }
+            else {
               status = F_status_set_error(F_found_not);
 
+              controller_print_error_rule_instance_need_want_wish(&main->program.error, instance, strings[i], dynamics[i]->array[j], "is not found");
+
               if (!(instance->options & controller_instance_option_simulate_e)) {
                 if (dependency) {
                   f_thread_unlock(&dependency->active);
@@ -215,17 +203,6 @@ extern "C" {
                 break;
               }
             }
-            else {
-              if (main->program.warning.verbosity == f_console_verbosity_debug_e) {
-                controller_lock_print(main->program.warning.to, &main->thread);
-
-                controller_print_error_rule_item_need_want_wish(&main->program.warning, strings[i], dynamics[i]->array[j], "is not found");
-
-                controller_print_error_rule_cache(&main->program.warning, &instance->cache.action, F_true);
-
-                controller_unlock_print_flush(main->program.warning.to, &main->thread);
-              }
-            }
           }
           else if (found) {
             status_lock = controller_lock_read_instance(instance, &main->thread.lock.rule);
@@ -303,12 +280,7 @@ extern "C" {
 
                 if (F_status_is_error(status)) {
                   if (i == 0 || i == 1 || F_status_set_fine(status) == F_memory_not) {
-                    controller_lock_print(main->program.error.to, &main->thread);
-
-                    controller_print_error_rule_item_need_want_wish(&main->program.error, strings[i], alias_other_buffer, "failed during execution");
-                    controller_print_error_rule_cache(&main->program.error, &instance->cache.action, F_true);
-
-                    controller_unlock_print_flush(main->program.error.to, &main->thread);
+                    controller_print_error_rule_instance_need_want_wish(&main->program.error, instance, strings[i], alias_other_buffer, "failed during execution");
 
                     if (!(dependency->options & controller_instance_option_simulate_e) || F_status_set_fine(status) == F_memory_not) {
                       f_thread_unlock(&dependency->active);
@@ -317,15 +289,7 @@ extern "C" {
                     }
                   }
                   else {
-                    if (main->program.warning.verbosity == f_console_verbosity_debug_e) {
-                      controller_lock_print(main->program.warning.to, &main->thread);
-
-                      controller_print_error_rule_item_need_want_wish(&main->program.warning, strings[i], alias_other_buffer, "failed during execution");
-
-                      controller_print_error_rule_cache(&main->program.warning, &instance->cache.action, F_true);
-
-                      controller_unlock_print_flush(main->program.warning.to, &main->thread);
-                    }
+                    controller_print_debug_rule_instance_need_want_wish(&main->program.warning, instance, strings[i], alias_other_buffer, "failed during execution");
                   }
                 }
               }
@@ -352,26 +316,18 @@ extern "C" {
             }
 
             if (F_status_is_error(status_lock)) {
-              if (F_status_is_error(status_lock)) {
-                controller_print_error_rule_item_need_want_wish(&main->program.error, strings[i], alias_other_buffer, "due to lock failure");
-              }
-
               status = status_lock;
+
+              controller_print_error_rule_instance_need_want_wish(&main->program.error, instance, strings[i], alias_other_buffer, "due to lock failure");
             }
             else if (controller_rule_status_is_error(instance->action, main->process.rules.array[id_rule])) {
               f_thread_unlock(&main->thread.lock.rule);
 
               if (i == 0 || i == 1) {
-                controller_lock_print(main->program.error.to, &main->thread);
-
-                controller_print_error_rule_item_need_want_wish(&main->program.error, strings[i], alias_other_buffer, "is in a failed state");
-
-                controller_print_error_rule_cache(&main->program.error, &instance->cache.action, F_true);
-
-                controller_unlock_print_flush(main->program.error.to, &main->thread);
-
                 status = F_status_set_error(F_found_not);
 
+                controller_print_error_rule_instance_need_want_wish(&main->program.error, instance, strings[i], alias_other_buffer, "is in a failed state");
+
                 if (!(dependency->options & controller_instance_option_simulate_e)) {
                   f_thread_unlock(&dependency->active);
 
@@ -379,15 +335,7 @@ extern "C" {
                 }
               }
               else {
-                if (main->program.warning.verbosity == f_console_verbosity_debug_e) {
-                  controller_lock_print(main->program.warning.to, &main->thread);
-
-                  controller_print_error_rule_item_need_want_wish(&main->program.warning, strings[i], alias_other_buffer, "is in a failed state");
-
-                  controller_print_error_rule_cache(&main->program.warning, &instance->cache.action, F_true);
-
-                  controller_unlock_print_flush(main->program.warning.to, &main->thread);
-                }
+                controller_print_debug_rule_instance_need_want_wish(&main->program.warning, instance, strings[i], alias_other_buffer, "is in a failed state");
               }
             }
             else {
@@ -441,9 +389,9 @@ extern "C" {
       }
 
       if (F_status_is_error_not(status)) {
-        status = controller_rule_execute(main, instance->action, instance->options, instance);
+        status = controller_rule_execute(main, instance, instance->action, instance->options);
 
-        if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock) return status;
+        if (status == F_child || F_status_set_fine(status) == F_interrupt || F_status_set_fine(status) == F_lock || F_status_set_fine(status) == F_lock_read) return status;
 
         if (F_status_is_error(status)) {
           controller_print_error_rule_item(&main->program.error, &instance->cache.action, F_true, F_status_set_fine(status));
@@ -460,10 +408,8 @@ extern "C" {
     if (F_status_is_error(status_lock)) {
       controller_print_error_lock_critical(&main->program.error, F_status_set_fine(status_lock), F_false);
 
-      if (F_status_set_fine(status) != F_interrupt) {
-        status = controller_lock_read_instance(instance, &instance->lock);
-        if (F_status_is_error_not(status)) return status_lock;
-      }
+      status_lock = controller_lock_read(instance->type != controller_instance_type_exit_e, F_false, &main->thread, &instance->lock);
+      if (F_status_is_error(status_lock)) return F_status_set_error(F_lock_read);
 
       return F_status_set_error(F_lock);
     }
@@ -480,10 +426,11 @@ extern "C" {
     if (F_status_is_error(status_lock)) {
       controller_print_error_lock_critical(&main->program.error, F_status_set_fine(status_lock), F_false);
 
+      // Remove the write lock and restore the read lock.
       f_thread_unlock(&instance->lock);
 
-      status = controller_lock_read_instance(instance, &instance->lock);
-      if (F_status_is_error_not(status)) return status_lock;
+      status_lock = controller_lock_read(instance->type != controller_instance_type_exit_e, F_false, &main->thread, &instance->lock);
+      if (F_status_is_error(status_lock)) return F_status_set_error(F_lock_read);
 
       return F_status_set_error(F_lock);
     }
@@ -496,15 +443,11 @@ extern "C" {
 
       f_number_unsigned_t j = 0;
 
-      controller_rule_item_t *rule_item = 0;
-
       // Copy all Rule Item Action statuses from the Rule instance to the Rule.
       for (i = 0; i < rule->items.used; ++i) {
 
-        rule_item = &rule->items.array[i];
-
-        for (j = 0; j < rule_item->actions.used; ++j) {
-          rule_item->actions.array[j].status = instance->rule.items.array[i].actions.array[j].status;
+        for (j = 0; j < rule->items.array[i].actions.used; ++j) {
+          rule->items.array[i].actions.array[j].status = instance->rule.items.array[i].actions.array[j].status;
         } // for
       } // for
     }
@@ -517,6 +460,9 @@ extern "C" {
     if (F_status_is_error(status_lock)) {
       controller_print_error_lock_critical(&main->program.error, F_status_set_fine(status_lock), F_true);
 
+      status_lock = controller_lock_read(instance->type != controller_instance_type_exit_e, F_false, &main->thread, &instance->lock);
+      if (F_status_is_error(status_lock)) return F_status_set_error(F_lock_read);
+
       return F_status_set_error(F_lock);
     }
 
index 71b9455e1139bd806cfa2e4fa0398fef6aeafe2d..f2dd83bbed0d875ed06e8ec59f3581be6d415d1f 100644 (file)
@@ -39,7 +39,8 @@ extern "C" {
  *   F_failure on execution failure.
  *
  *   F_interrupt (with error bit) on receiving a instance signal, such as an interrupt signal.
- *   F_lock (with error bit) if failed to re-establish read lock on instance->lock while returning.
+ *   F_lock (with error bit) if failed to establish a lock, and the instance->lock read lock is already restored.
+ *   F_lock_read (with error bit) if failed to re-establish read lock on instance->lock while returning.
  *
  *   Errors (with error bit) from: controller_lock_read().
  *   Errors (with error bit) from: controller_lock_write().