From b65e5c1d45c8bfc38b3745cb28ac9074b1c1bdc1 Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Fri, 23 Feb 2024 13:27:38 +0100 Subject: irmd: Always use reg_destroy_proc Destroying a process will now always be done with reg_destroy_proc, regardless of whether it was an IPCP or spawned. This makes it easier to keep the registry consistent and avoid races. Also improves some logs and updates some default settings. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/irmd/main.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/irmd/main.c') diff --git a/src/irmd/main.c b/src/irmd/main.c index 32f41ab2..e2503d0c 100644 --- a/src/irmd/main.c +++ b/src/irmd/main.c @@ -268,7 +268,7 @@ int create_ipcp(struct ipcp_info * info) fail_boot: waitpid(info->pid, &status, 0); - reg_destroy_ipcp(info->pid); + reg_destroy_proc(info->pid); return -1; fail_reg_ipcp: @@ -289,7 +289,7 @@ static int destroy_ipcp(pid_t pid) goto fail; } - if (reg_destroy_ipcp(pid)) { + if (reg_destroy_proc(pid)) { log_err("Failed to remove IPCP from registry."); goto fail; } @@ -741,9 +741,6 @@ static int proc_announce(const struct proc_info * info) static int proc_exit(pid_t pid) { - if (reg_has_ipcp(pid) && reg_destroy_ipcp(pid) < 0) - log_warn("Failed to remove IPCP %d.", pid); - if (reg_destroy_proc(pid) < 0) log_err("Failed to remove process %d.", pid); @@ -1023,12 +1020,12 @@ static int flow_alloc(struct flow_info * flow, uint8_t * s = NULL; buffer_t hash; int err; - /* piggyback of user data not yet implemented */ assert(data != NULL && data->len == 0 && data->data == NULL); log_info("Allocating flow for %d to %s.", flow->n_pid, dst); + if (flow->qs.cypher_s > 0) { ssize_t key_len; @@ -2025,8 +2022,8 @@ static void kill_all_spawned(void) waitpid(pid, &s, 0); else { log_warn("Child process %d died.", pid); - reg_destroy_spawned(pid); cleanup_pid(pid); + reg_destroy_proc(pid); } pid = reg_first_spawned(); } -- cgit v1.2.3