build_libraries-monolithic -lfll
build_sources_library main/common.c main/common/define.c main/common/enumeration.c main/common/print.c main/common/string.c main/common/type.c
-build_sources_library main/common/type/cache.c main/common/type/control.c main/common/type/entry.c main/common/type/process.c main/common/type/rule.c
+build_sources_library main/common/type/cache.c main/common/type/control.c main/common/type/entry.c main/common/type/lock.c main/common/type/process.c main/common/type/rule.c main/common/type/thread.c
build_sources_library main/common/string/general.c main/common/string/rule.c
build_sources_library main/print/data.c main/print/debug.c main/print/error.c main/print/message.c main/print/verbose.c main/print/warning.c
build_sources_library main/signal.c main/thread.c
build_sources_headers main/common.h main/controller.h main/common/define.h main/common/enumeration.h main/common/print.h main/common/string.h main/common/type.h
-build_sources_headers main/common/define/control.h main/common/define/entry.h main/common/define/rule.h
-build_sources_headers main/common/enumeration/control.h main/common/enumeration/entry.h main/common/enumeration/process.h main/common/enumeration/rule.h
+build_sources_headers main/common/define/control.h main/common/define/entry.h main/common/define/rule.h main/common/define/thread.h
+build_sources_headers main/common/enumeration/control.h main/common/enumeration/entry.h main/common/enumeration/process.h main/common/enumeration/rule.h main/common/enumeration/thread.h
build_sources_headers main/common/string/general.h main/common/string/rule.h
-build_sources_headers main/common/type/cache.h main/common/type/control.h main/common/type/entry.h main/common/type/process.h main/common/type/rule.h
+build_sources_headers main/common/type/cache.h main/common/type/control.h main/common/type/entry.h main/common/type/lock.h main/common/type/process.h main/common/type/rule.h main/common/type/thread.h
build_sources_headers main/print/data.h main/print/debug.h main/print/error.h main/print/message.h main/print/verbose.h main/print/warning.h
build_sources_headers main/signal.h main/thread.h
#endif
#ifndef _di_controller_controller_main_
- void controller_controller_main(controller_main_t * const main) {
+ void controller_controller_main(controller_main_t * const main, controller_process_t * const process) {
- if (!main) return;
+ if (!main || !process) return;
if (F_status_is_error(main->setting.state.status)) {
if ((main->setting.flag & controller_main_flag_print_last_e) && main->program.message.verbosity > f_console_verbosity_error_e) {
#include <fll/level_0/execute.h>
#include <fll/level_0/iki.h>
#include <fll/level_0/limit.h>
+#include <fll/level_0/path.h>
#include <fll/level_0/pipe.h>
#include <fll/level_0/print.h>
#include <fll/level_0/rip.h>
#include <program/controller/main/common/define/control.h>
#include <program/controller/main/common/define/entry.h>
#include <program/controller/main/common/define/rule.h>
+#include <program/controller/main/common/define/thread.h>
#include <program/controller/main/common/enumeration/control.h>
#include <program/controller/main/common/enumeration/entry.h>
#include <program/controller/main/common/enumeration/rule.h>
#include <program/controller/main/common/enumeration/process.h>
+#include <program/controller/main/common/enumeration/thread.h>
#include <program/controller/main/common/type/cache.h>
#include <program/controller/main/common/type/control.h>
#include <program/controller/main/common/type/entry.h>
+#include <program/controller/main/common/type/lock.h>
#include <program/controller/main/common/type/rule.h>
#include <program/controller/main/common/type/process.h>
+#include <program/controller/main/common/type/thread.h>
#include <program/controller/main/common/type.h>
#include <program/controller/main/common.h>
#include <program/controller/main/print/data.h>
* @param main
* The main program data and settings.
*
+ * Must not be NULL.
+ *
* This alters main.setting.state.status:
* F_okay on success.
* F_true on success when performing verification and verify passed.
* F_interrupt on (exit) signal received.
*
* F_parameter (with error bit) if main is NULL or setting is NULL.
+ * @param process
+ * A pointer to the current process settings.
+ *
+ * Must not be NULL.
*/
#ifndef _di_controller_controller_main_
- extern void controller_controller_main(controller_main_t * const main);
+ extern void controller_controller_main(controller_main_t * const main, controller_process_t * const process);
#endif // _di_controller_controller_main_
#ifdef __cplusplus
int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
controller_main_t data = controller_main_t_initialize;
+ controller_process_t process = controller_process_t_initialize;
data.program.debug.flag |= controller_print_flag_debug_e | controller_print_flag_out_e;
data.program.error.flag |= controller_print_flag_error_e | controller_print_flag_out_e;
{
const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize_1(argc, argv, envp);
- controller_main_setting_load(arguments, &data);
+ controller_main_setting_load(arguments, &data, &process);
}
- controller_controller_main(&data);
+ controller_controller_main(&data, &process);
#else
{
f_thread_id_t id_signal;
{
const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize_1(argc, argv, envp);
- controller_main_setting_load(arguments, &data);
+ controller_main_setting_load(arguments, &data, &process);
}
if (!controller_main_signal_check(&data)) {
- controller_controller_main(&data);
+ controller_controller_main(&data, &process);
}
f_thread_cancel(id_signal);
#include <fll/level_0/execute.h>
#include <fll/level_0/iki.h>
#include <fll/level_0/limit.h>
+#include <fll/level_0/path.h>
#include <fll/level_0/pipe.h>
#include <fll/level_0/print.h>
#include <fll/level_0/rip.h>
#include <program/controller/main/common/define/control.h>
#include <program/controller/main/common/define/entry.h>
#include <program/controller/main/common/define/rule.h>
+#include <program/controller/main/common/define/thread.h>
#include <program/controller/main/common/enumeration/control.h>
#include <program/controller/main/common/enumeration/entry.h>
#include <program/controller/main/common/enumeration/rule.h>
#include <program/controller/main/common/enumeration/process.h>
+#include <program/controller/main/common/enumeration/thread.h>
#include <program/controller/main/common/type/cache.h>
#include <program/controller/main/common/type/control.h>
#include <program/controller/main/common/type/entry.h>
+#include <program/controller/main/common/type/lock.h>
#include <program/controller/main/common/type/rule.h>
#include <program/controller/main/common/type/process.h>
+#include <program/controller/main/common/type/thread.h>
#include <program/controller/main/common/type.h>
#include <program/controller/main/common.h>
#include <program/controller/main/print/data.h>
int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
controller_main_t data = controller_main_t_initialize;
+ controller_process_t process = controller_process_t_initialize;
data.program.debug.flag |= controller_print_flag_debug_e | controller_print_flag_out_e;
data.program.error.flag |= controller_print_flag_error_e | controller_print_flag_out_e;
{
const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize_1(argc, argv, envp);
- controller_main_setting_load(arguments, &data);
+ controller_main_setting_load(arguments, &data, &process);
}
controller_init_main(&data);
{
const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize_1(argc, argv, envp);
- controller_main_setting_load(arguments, &data);
+ controller_main_setting_load(arguments, &data, &process);
}
if (!controller_main_signal_check(&data)) {
#endif
#ifndef _di_controller_main_setting_load_
- void controller_main_setting_load(const f_console_arguments_t arguments, controller_main_t * const main) {
+ void controller_main_setting_load(const f_console_arguments_t arguments, controller_main_t * const main, controller_process_t * const process) {
if (!main) return;
else {
main->setting.flag &= ~controller_main_flag_pipe_e;
}
+
+ f_string_static_t * const args = main->program.parameters.arguments.array;
+
+ process->control.server.domain = f_socket_protocol_family_local_e;
+ process->control.server.type = f_socket_type_stream_e;
+ process->control.server.form = f_socket_address_form_local_e;
+
+ memset(&process->control.server.address, 0, sizeof(f_socket_address_t));
+
+ // The first remaining argument represents the entry name.
+ main->setting.state.status = f_string_dynamic_append(main->program.parameters.remaining.used ? args[main->program.parameters.remaining.array[0]] : controller_default_s, &process->name_entry);
+
+ if (F_status_is_error(main->setting.state.status)) {
+ if ((main->setting.flag & controller_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) {
+ fll_print_dynamic_raw(f_string_eol_s, main->program.message.to);
+ }
+
+ controller_main_print_error(&main->program.error, macro_controller_f(fll_program_parameter_process_verbosity_standard));
+
+ return;
+ }
+
+ main->setting.state.status = f_path_current(F_false, &process->path_current);
+
+ if (F_status_is_error(main->setting.state.status)) {
+ if ((main->setting.flag & controller_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) {
+ fll_print_dynamic_raw(f_string_eol_s, main->program.message.to);
+ }
+
+ controller_main_print_error(&main->program.error, macro_controller_f(f_path_current));
+
+ return;
+ }
}
#endif // _di_controller_main_setting_load_
*
* Errors (with error bit) from: f_console_parameter_process().
* Errors (with error bit) from: fll_program_parameter_process_context().
+ * @param process
+ * A pointer to the current process settings.
+ *
+ * Must not be NULL.
*
* @see f_console_parameter_process()
* @see fll_program_parameter_process_context()
*/
#ifndef _di_controller_main_setting_load_
- extern void controller_main_setting_load(const f_console_arguments_t arguments, controller_main_t * const main);
+ extern void controller_main_setting_load(const f_console_arguments_t arguments, controller_main_t * const main, controller_process_t * const process);
#endif // _di_controller_main_setting_load_
#ifdef __cplusplus
--- /dev/null
+/**
+ * FLL - Level 3
+ *
+ * Project: Controller
+ * API Version: 0.7
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Provides the common thread defines.
+ *
+ * This is auto-included and should not need to be explicitly included.
+ */
+#ifndef _controller_main_common_define_thread_h
+#define _controller_main_common_define_thread_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Thread related defines.
+ */
+#ifndef _di_controller_thread_d_
+ #define controller_thread_cleanup_interval_long_d 3600 // 1 hour in seconds.
+ #define controller_thread_cleanup_interval_short_d 180 // 3 minutes in seconds.
+ #define controller_thread_exit_timeout_d 500 // 0.5 seconds in milliseconds.
+ #define controller_thread_exit_process_cancel_wait_d 600000000 // 0.6 seconds in nanoseconds.
+ #define controller_thread_exit_process_cancel_total_d 150 // 90 seconds in multiples of wait.
+ #define controller_thread_simulation_timeout_d 200 // 0.2 seconds in milliseconds.
+
+ #define controller_thread_signal_wait_timeout_seconds_d 70
+ #define controller_thread_signal_wait_timeout_nanoseconds_d 0
+
+ #define controller_thread_lock_read_timeout_seconds_d 3
+ #define controller_thread_lock_read_timeout_nanoseconds_d 0
+ #define controller_thread_lock_write_timeout_seconds_d 3
+ #define controller_thread_lock_write_timeout_nanoseconds_d 0
+
+ #define controller_thread_wait_timeout_1_before_d 4
+ #define controller_thread_wait_timeout_2_before_d 12
+ #define controller_thread_wait_timeout_3_before_d 28
+
+ #define controller_thread_wait_timeout_1_seconds_d 0
+ #define controller_thread_wait_timeout_1_nanoseconds_d 20000000 // 0.02 seconds in nanoseconds.
+ #define controller_thread_wait_timeout_2_seconds_d 0
+ #define controller_thread_wait_timeout_2_nanoseconds_d 200000000 // 0.2 seconds in nanoseconds.
+ #define controller_thread_wait_timeout_3_seconds_d 2
+ #define controller_thread_wait_timeout_3_nanoseconds_d 0
+ #define controller_thread_wait_timeout_4_seconds_d 20
+ #define controller_thread_wait_timeout_4_nanoseconds_d 0
+
+ #define controller_thread_exit_helper_timeout_seconds_d 0
+ #define controller_thread_exit_helper_timeout_nanoseconds_d 100000000 // 0.1 seconds in nanoseconds.
+
+ #define controller_thread_exit_ready_timeout_seconds_d 0
+ #define controller_thread_exit_ready_timeout_nanoseconds_d 500000000 // 0.5 seconds in nanoseconds.
+#endif // _di_controller_thread_d_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _controller_main_common_define_thread_h
--- /dev/null
+/**
+ * FLL - Level 3
+ *
+ * Project: Controller
+ * API Version: 0.7
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Provides the common thread enumerations.
+ *
+ * This is auto-included and should not need to be explicitly included.
+ */
+#ifndef _controller_main_common_enumeration_thread_h
+#define _controller_main_common_enumeration_thread_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ /**
+ * States for the thread, designating how to stop the process.
+ *
+ * controller_thread_*_e:
+ * - enabled_not: The controller is no longer enabled, shut down and abort all work.
+ * - enabled: The controller is operating normally.
+ * - enabled_execute: The controller is executing another process, all running operations must terminate.
+ * - enabled_exit: The controller is shutting down, only process exit rules.
+ * - enabled_exit_execute: The controller is executing another process while in failsafe mode, all running operations must terminate.
+ * - enabled_exit_ready: The controller is shutting down, only process exit rules, and now ready to send termination signals.
+ */
+ enum {
+ controller_thread_enabled_not_e = 0,
+ controller_thread_enabled_e,
+ controller_thread_enabled_execute_e,
+ controller_thread_enabled_exit_e,
+ controller_thread_enabled_exit_execute_e,
+ controller_thread_enabled_exit_ready_e,
+ }; // enum
+
+ /**
+ * States for the thread, designating how the process is cancelled.
+ *
+ * controller_thread_cancel_*_e:
+ * - signal: Cancellation is triggered by a signal.
+ * - call: Cancellation is explicitly called.
+ * - execute: Cancellation is explicitly called due to an "execute" Item Action, when not during Exit.
+ * - exit: Cancellation is explicitly called during Exit.
+ * - exit_execute: Cancellation is explicitly called due to an "execute" Item Action during Exit.
+ */
+ enum {
+ controller_thread_cancel_signal_e = 0,
+ controller_thread_cancel_call_e,
+ controller_thread_cancel_execute_e,
+ controller_thread_cancel_exit_e,
+ controller_thread_cancel_exit_execute_e,
+ }; // enum
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _controller_main_common_enumeration_thread_h
#ifndef _di_controller_f_a_
const f_string_t controller_f_a[] = {
"f_console_parameter_process",
+ "f_path_current",
+ "f_string_dynamic_append",
"f_thread_create",
"fll_program_parameter_process_context_standard",
"fll_program_parameter_process_verbosity_standard",
#ifndef _di_controller_f_e_
enum {
controller_f_f_console_parameter_process_e,
+ controller_f_f_path_current_e,
+ controller_f_f_string_dynamic_append_e,
controller_f_f_thread_create_e,
controller_f_fll_program_parameter_process_context_standard_e,
controller_f_fll_program_parameter_process_verbosity_standard_e,
* API Version: 0.7
* Licenses: lgpl-2.1-or-later
*
- * Provides the common type cache structures.
+ * Provides the common cache type structures.
*
* This is auto-included and should not need to be explicitly included.
*/
* API Version: 0.7
* Licenses: lgpl-2.1-or-later
*
- * Provides the common type control structures.
+ * Provides the common control type structures.
*
* This is auto-included and should not need to be explicitly included.
*/
/**
* Controller control data.
*
- * flag: Flags from controller_control_flag_*_e.
- * user: The user ID, if specified.
- * group: The group ID, if specified.
- * mode: The file mode, if specified.
- * server: The server socket connection.
- * client: The client socket connection.
+ * flag: Flags from controller_control_flag_*_e.
+ * user: The user ID, if specified.
+ * group: The group ID, if specified.
+ * mode: The file mode, if specified.
+ *
+ * server: The server socket connection.
+ * client: The client socket connection.
+ *
* cache_1: A generic buffer used for caching control related data.
* cache_2: A generic buffer used for caching control related data.
* cache_3: A generic buffer used for caching control related data.
+ *
* input: A buffer used for receiving data from the client.
* output: A buffer used for transmitting data to the client.
- * address: The socket address structure.
*/
#ifndef _di_controller_control_t_
typedef struct {
uint8_t flag;
-
uid_t user;
gid_t group;
mode_t mode;
f_string_dynamic_t input;
f_string_dynamic_t output;
-
- struct sockaddr_un address;
} controller_control_t;
#define controller_control_t_initialize { \
f_string_dynamic_t_initialize, \
f_string_dynamic_t_initialize, \
f_string_dynamic_t_initialize, \
- { }, \
}
#endif // _di_controller_control_t_
* API Version: 0.7
* Licenses: lgpl-2.1-or-later
*
- * Provides the common type entry structures.
+ * Provides the common entry type structures.
*
* This is auto-included and should not need to be explicitly included.
*/
--- /dev/null
+#include "../../controller.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _di_controller_lock_delete_mutex_
+ void controller_lock_delete_mutex(f_thread_mutex_t *mutex) {
+
+ const f_status_t status = f_thread_mutex_delete(mutex);
+
+ if (F_status_is_error(status)) {
+ if (F_status_set_fine(status) == F_busy) {
+ if (f_thread_mutex_delete(mutex) == F_okay) {
+ mutex = 0;
+ }
+ }
+ }
+ else {
+ mutex = 0;
+ }
+ }
+#endif // _di_controller_lock_delete_mutex_
+
+#ifndef _di_controller_lock_delete_rw_
+ void controller_lock_delete_rw(f_thread_lock_t *lock) {
+
+ const f_status_t status = f_thread_lock_delete(lock);
+
+ if (F_status_is_error(status)) {
+ if (F_status_set_fine(status) == F_busy) {
+ if (f_thread_lock_delete(lock) == F_okay) {
+ lock = 0;
+ }
+ }
+ }
+ else {
+ lock = 0;
+ }
+ }
+#endif // _di_controller_lock_delete_rw_
+
+#ifndef _di_controller_lock_delete_
+ void controller_lock_delete(controller_lock_t * const lock) {
+
+ controller_lock_delete_mutex(&lock->alert);
+ controller_lock_delete_mutex(&lock->cancel);
+ controller_lock_delete_mutex(&lock->print);
+
+ controller_lock_delete_rw(&lock->process);
+ controller_lock_delete_rw(&lock->rule);
+
+ f_thread_condition_delete(&lock->alert_condition);
+ }
+#endif // _di_controller_lock_delete_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 3
+ *
+ * Project: Controller
+ * API Version: 0.7
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Provides the common lock type structures.
+ *
+ * This is auto-included and should not need to be explicitly included.
+ */
+#ifndef _controller_main_common_type_lock_h
+#define _controller_main_common_type_lock_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+/**
+ * A structure for sharing mutexes globally between different threads.
+ *
+ * The alert lock is intended for a generic waiting on alerts operations.
+ * The cancel lock is intended for preventing double cancellation calls (which can happen due to interrupts).
+ * The print lock is intended to lock any activity printing to stdout/stderr.
+ * The process lock is intended to lock any activity on the process structure.
+ * The rule lock is intended to lock any activity on the rules structure.
+ *
+ * alert: The alert mutex lock for waking up on alerts.
+ * cancel: The cancel mutex lock for locking the cancel operation.
+ * print: The print mutex lock.
+ * process: The process r/w lock.
+ * rule: The rule r/w lock.
+ * alert_condition: The condition used to trigger alerts.
+ */
+#ifndef _di_controller_lock_t_
+ typedef struct {
+ f_thread_mutex_t alert;
+ f_thread_mutex_t cancel;
+ f_thread_mutex_t print;
+
+ f_thread_lock_t process;
+ f_thread_lock_t rule;
+
+ f_thread_condition_t alert_condition;
+ } controller_lock_t;
+
+ #define controller_lock_t_initialize { \
+ f_thread_mutex_t_initialize, \
+ f_thread_mutex_t_initialize, \
+ f_thread_mutex_t_initialize, \
+ f_thread_lock_t_initialize, \
+ f_thread_lock_t_initialize, \
+ f_thread_condition_t_initialize, \
+ }
+#endif // _di_controller_lock_t_
+
+/**
+ * Delete the mutex lock and if the mutex lock is busy, forcibly unlock it and then delete it.
+ *
+ * @param mutex
+ * The mutex lock to delete.
+ * Will be set to NULL if delete succeeded.
+ *
+ * This pointer cannot be "* const" because of pthread_mutex_destroy().
+ *
+ * @see f_thread_mutex_delete()
+ */
+#ifndef _di_controller_lock_delete_mutex_
+ extern void controller_lock_delete_mutex(f_thread_mutex_t *mutex);
+#endif // _di_controller_lock_delete_mutex_
+
+/**
+ * Delete the r/w lock and if the r/w lock is busy, forcibly unlock it and then delete it.
+ *
+ * @param lock
+ * The r/w lock to delete.
+ * Will be set to NULL if delete succeeded.
+ *
+ * This pointer cannot be "* const" because of pthread_rwlock_destroy().
+ *
+ * @see f_thread_lock_delete()
+ */
+#ifndef _di_controller_lock_delete_rw_
+ extern void controller_lock_delete_rw(f_thread_lock_t *lock);
+#endif // _di_controller_lock_delete_rw_
+
+/**
+ * Fully deallocate all memory for the given lock without caring about return status.
+ *
+ * @param lock
+ * The lock to deallocate.
+ *
+ * @see f_thread_lock_delete()
+ * @see f_thread_mutex_delete()
+ */
+#ifndef _di_controller_lock_delete_
+ extern void controller_lock_delete(controller_lock_t * const lock);
+#endif // _di_controller_lock_delete_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _controller_main_common_type_lock_h
f_memory_array_resize(0, sizeof(f_char_t), (void **) &process->path_pid.string, &process->path_pid.used, &process->path_pid.size);
f_memory_array_resize(0, sizeof(f_char_t), (void **) &process->path_setting.string, &process->path_setting.used, &process->path_setting.size);
- controller_control_delete(&process->control);
-
f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &process->entry.define.array, &process->entry.define.used, &process->entry.define.size, &f_string_maps_delete_callback);
f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &process->entry.parameter.array, &process->entry.parameter.used, &process->entry.parameter.size, &f_string_maps_delete_callback);
f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &process->exit.define.array, &process->exit.define.used, &process->exit.define.size, &f_string_maps_delete_callback);
f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &process->exit.parameter.array, &process->exit.parameter.used, &process->exit.parameter.size, &f_string_maps_delete_callback);
+ controller_control_delete(&process->control);
controller_entry_items_delete(&process->entry.items);
controller_entry_items_delete(&process->exit.items);
* API Version: 0.7
* Licenses: lgpl-2.1-or-later
*
- * Provides the common type process structures.
+ * Provides the common process type structures.
*
* This is auto-included and should not need to be explicitly included.
*/
/**
* Controller process data.
*
- * ready: State representing if the settings are all loaded and is ready to run program operations.
- * mode: Controller setting mode based on the setting mode enumerator.
- * control: The control socket data.
+ * ready: State representing if the settings are all loaded and is ready to run program operations.
+ * mode: Controller setting mode based on the setting mode enumerator.
+ *
* failsafe_item_id: The Entry Item ID to execute when failsafe execution is enabled.
- * path_cgroup: Directory path to the cgroup directory.
- * path_control: File path to the control socket (used for printing the path).
- * path_pid: File path to the PID file.
- * path_setting: File path to the setting directory.
- * entry: The Entry settings.
- * rules: All rules and their respective settings.
+ *
+ * name_entry: The name of the entry file.
+ * path_cgroup: Directory path to the cgroup directory.
+ * path_control: File path to the control socket (used for printing the path).
+ * path_current: The current path.
+ * path_pid: File path to the PID file.
+ * path_setting: File path to the setting directory.
+ *
+ * control: The control socket data.
+ * entry: The Entry settings.
+ * exit: The Exit settings.
+ * rules: All rules and their respective settings.
*/
#ifndef _di_controller_process_t_
typedef struct {
f_number_unsigned_t failsafe_item_id;
- controller_control_t control;
-
+ f_string_dynamic_t name_entry;
f_string_dynamic_t path_cgroup;
f_string_dynamic_t path_control;
f_string_dynamic_t path_current;
f_string_dynamic_t path_pid;
f_string_dynamic_t path_setting;
- f_string_dynamic_t name_entry;
-
+ controller_control_t control;
controller_entry_t entry;
controller_entry_t exit;
controller_rules_t rules;
0, \
0, \
0, \
- 0, \
- controller_control_t_initialize, \
f_string_dynamic_t_initialize, \
f_string_dynamic_t_initialize, \
f_string_dynamic_t_initialize, \
f_string_dynamic_t_initialize, \
f_string_dynamic_t_initialize, \
f_string_dynamic_t_initialize, \
+ controller_control_t_initialize, \
controller_entry_t_initialize, \
controller_entry_t_initialize, \
controller_rules_t_initialize, \
* API Version: 0.7
* Licenses: lgpl-2.1-or-later
*
- * Provides the common type rules structures.
+ * Provides the common rules type structures.
*
* This is auto-included and should not need to be explicitly included.
*/
--- /dev/null
+#include "../../controller.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _di_controller_thread_delete_simple_
+ void controller_thread_delete_simple(controller_thread_t * const thread) {
+
+ controller_lock_delete(&thread->lock);
+ controller_process_delete(&thread->process);
+ controller_cache_delete(&thread->cache);
+ }
+#endif // _di_controller_thread_delete_simple_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 3
+ *
+ * Project: Controller
+ * API Version: 0.7
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Provides the common thread type structures.
+ *
+ * This is auto-included and should not need to be explicitly included.
+ */
+#ifndef _controller_main_common_type_thread_h
+#define _controller_main_common_type_thread_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * A structure for managing threads.
+ *
+ * This is essentially data shared globally between threads, about threads.
+ *
+ * The "enabled" and "signal" utilize the lock: lock.process.
+ *
+ * enabled: TRUE when threads are active, FALSE when inactive and the program is essentially shutting down, no new threads should be started when FALSE.
+ * signal: The code of any signal received.
+ * status: A status used by the main entry/rule processing thread for synchronous operations.
+ *
+ * id_cleanup: The thread ID representing the Cleanup Process.
+ * id_control: The thread ID representing the Control Process.
+ * id_entry: The thread ID representing the Entry or Exit Process.
+ * id_rule: The thread ID representing the Rule Process.
+ * id_signal: The thread ID representing the Signal Process.
+ *
+ * lock: A r/w lock for operating on this structure.
+ * process: All Rule Process thread data.
+ * cache: A cache used by the main entry/rule processing thread for synchronous operations.
+ */
+#ifndef _di_controller_thread_t_
+ typedef struct {
+ uint8_t enabled;
+ int signal;
+ f_status_t status;
+
+ f_thread_id_t id_cleanup;
+ f_thread_id_t id_control;
+ f_thread_id_t id_entry;
+ f_thread_id_t id_rule;
+ f_thread_id_t id_signal;
+
+ controller_lock_t lock;
+ controller_process_t process;
+ controller_cache_t cache;
+ } controller_thread_t;
+
+ #define controller_thread_t_initialize { \
+ controller_thread_enabled_e, \
+ 0, \
+ F_none, \
+ f_thread_id_t_initialize, \
+ f_thread_id_t_initialize, \
+ f_thread_id_t_initialize, \
+ f_thread_id_t_initialize, \
+ f_thread_id_t_initialize, \
+ controller_lock_t_initialize, \
+ controller_processs_t_initialize, \
+ controller_cache_t_initialize, \
+ }
+#endif // _di_controller_thread_t_
+
+/**
+ * Fully deallocate all memory for the given setting without caring about return status.
+ *
+ * @param thread
+ * The thread to deallocate.
+ *
+ * @see controller_asynchronouss_resize()
+ * @see f_thread_mutex_unlock()
+ */
+#ifndef _di_controller_thread_delete_simple_
+ extern void controller_thread_delete_simple(controller_thread_t * const thread);
+#endif // _di_controller_thread_delete_simple_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _controller_main_common_type_thread_h
#include <fll/level_0/execute.h>
#include <fll/level_0/iki.h>
#include <fll/level_0/limit.h>
+#include <fll/level_0/path.h>
#include <fll/level_0/pipe.h>
#include <fll/level_0/print.h>
#include <fll/level_0/rip.h>
#include <program/controller/main/common/define/control.h>
#include <program/controller/main/common/define/entry.h>
#include <program/controller/main/common/define/rule.h>
+#include <program/controller/main/common/define/thread.h>
#include <program/controller/main/common/enumeration/control.h>
#include <program/controller/main/common/enumeration/entry.h>
#include <program/controller/main/common/enumeration/rule.h>
#include <program/controller/main/common/enumeration/process.h>
+#include <program/controller/main/common/enumeration/thread.h>
#include <program/controller/main/common/type/cache.h>
#include <program/controller/main/common/type/control.h>
#include <program/controller/main/common/type/entry.h>
+#include <program/controller/main/common/type/lock.h>
#include <program/controller/main/common/type/rule.h>
#include <program/controller/main/common/type/process.h>
+#include <program/controller/main/common/type/thread.h>
#include <program/controller/main/common/type.h>
#include <program/controller/main/common.h>
#include <program/controller/main/print/data.h>