diff options
author | Dimitri Staessens <[email protected]> | 2024-02-17 10:19:46 +0100 |
---|---|---|
committer | Sander Vrijders <[email protected]> | 2024-02-19 11:49:07 +0100 |
commit | 06ee3370998f965b469d1c2859e3e34159c71e20 (patch) | |
tree | 93881747a4f1e99f6932231b0cb2358941cb9741 /src/irmd/reg/name.h | |
parent | 7bb8aed15c7f29de4d9719acf8db7fdf73731af5 (diff) | |
download | ouroboros-06ee3370998f965b469d1c2859e3e34159c71e20.tar.gz ouroboros-06ee3370998f965b469d1c2859e3e34159c71e20.zip |
irmd: Revise IRMd internals
This is a full revision of the IRMd internal implementation.
The registry is now a proper subcomponent managing its own internal
lock (a single mutex). Some tests are added for the registry and its
data structures. Some macros for tests are added in <ouroboros/test.h>.
Flow allocation is now more symmetric between the client side (alloc)
and server size (accept). Each will create a flow in pending state
(ALLOC_PENDING/ACCEPT_PENDING) that is potentially fulfilled by an
IPCP using respond_alloc and respond_accept primitives. Deallocation
is split in flow_dealloc (application side) and ipcp_flow_dealloc
(IPCP side) to get the flow in DEALLOC_PENDING and DEALLOCATED state.
Cleanup of failed flow allocation is now properly handled instead of
relying on the sanitizer thread. The new sanitizer only needs to
monitor crashed processes.
On shutdown, the IRMd will now detect hanging processes and SIGKILL
them and clean up their fuse mountpoints if needed.
A lot of other things have been cleaned up and shuffled around a bit.
Signed-off-by: Dimitri Staessens <[email protected]>
Signed-off-by: Sander Vrijders <[email protected]>
Diffstat (limited to 'src/irmd/reg/name.h')
-rw-r--r-- | src/irmd/reg/name.h | 95 |
1 files changed, 35 insertions, 60 deletions
diff --git a/src/irmd/reg/name.h b/src/irmd/reg/name.h index 3b570424..97ca7f04 100644 --- a/src/irmd/reg/name.h +++ b/src/irmd/reg/name.h @@ -23,81 +23,56 @@ #ifndef OUROBOROS_IRMD_REG_NAME_H #define OUROBOROS_IRMD_REG_NAME_H -#include <ouroboros/hash.h> -#include <ouroboros/ipcp.h> #include <ouroboros/list.h> -#include <ouroboros/irm.h> - -#include "proc.h" -#include "prog.h" - -#include <stdint.h> -#include <stdbool.h> -#include <pthread.h> -#include <string.h> -#include <sys/types.h> - -enum name_state { - NAME_NULL = 0, - NAME_IDLE, - NAME_AUTO_ACCEPT, - NAME_AUTO_EXEC, - NAME_FLOW_ACCEPT, - NAME_FLOW_ARRIVED, - NAME_DESTROY -}; +#include <ouroboros/name.h> + +#define BIND_AUTO 0x01 -/* An entry in the registry */ struct reg_name { - struct list_head next; - char * name; - - /* Policies for this name. */ - enum pol_balance pol_lb; /* Load balance incoming flows. */ - /* Programs that can be instantiated by the irmd. */ - struct list_head reg_progs; - /* Processes that are listening for this name. */ - struct list_head reg_pids; - - enum name_state state; - pthread_cond_t cond; - pthread_mutex_t mtx; -}; + struct list_head next; -struct reg_name * reg_name_create(const char * name, - enum pol_balance lb); + struct name_info info; -void reg_name_destroy(struct reg_name * n); + struct list_head progs; /* autostart programs for this name */ + size_t n_progs; /* number of programs */ -int reg_name_add_prog(struct reg_name * n, - struct reg_prog * p); + struct list_head procs; /* processes bound to this name */ + size_t n_procs; /* number of processes */ -void reg_name_del_prog(struct reg_name * n, - const char * prog); + struct list_head active; /* processes actively calling accept */ + size_t n_active; /* number of processes accepting */ +}; -char * reg_name_get_prog(struct reg_name * n); +struct reg_name * reg_name_create(const struct name_info * info); -int reg_name_add_pid(struct reg_name * n, - pid_t pid); +void reg_name_destroy(struct reg_name * name); -void reg_name_del_pid(struct reg_name * n, - pid_t pid); +int reg_name_add_proc(struct reg_name * name, + pid_t proc); -void reg_name_del_pid_el(struct reg_name * n, - struct pid_el * p); +void reg_name_del_proc(struct reg_name * name, + pid_t proc); + +bool reg_name_has_proc(const struct reg_name * name, + pid_t proc); + +int reg_name_add_prog(struct reg_name * name, + char ** exec); + +void reg_name_del_prog(struct reg_name * name, + const char * prog); -pid_t reg_name_get_pid(struct reg_name * n); +bool reg_name_has_prog(const struct reg_name * name, + const char * prog); -void reg_name_set_policy(struct reg_name * n, - enum pol_balance lb); +char ** reg_name_get_exec(const struct reg_name * name); -enum name_state reg_name_get_state(struct reg_name * n); +int reg_name_add_active(struct reg_name * name, + pid_t proc); -int reg_name_set_state(struct reg_name * n, - enum name_state state); +pid_t reg_name_get_active(struct reg_name * name); -int reg_name_leave_state(struct reg_name * n, - enum name_state state, - struct timespec * timeout); +void reg_name_del_active(struct reg_name * name, + pid_t proc); #endif /* OUROBOROS_IRMD_REG_NAME_H */ |