From 639a17a3ac9236494b814e51a34583b4dccd754c Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Wed, 25 Apr 2018 20:26:29 +0200 Subject: irmd: Shut down IPCPs before IRMd internals This will shut down IPCPs before destroying IRMd internals. This fixes warnings from IPCPs trying to send messages and send packets upon IRM shutdown. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/irmd/main.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/irmd/main.c b/src/irmd/main.c index dfdc7539..db9d7bbd 100644 --- a/src/irmd/main.c +++ b/src/irmd/main.c @@ -1570,25 +1570,8 @@ static void irm_fini(void) if (irmd_get_state() != IRMD_NULL) log_warn("Unsafe destroy."); - close(irmd.sockfd); - - if (unlink(IRM_SOCK_PATH)) - log_dbg("Failed to unlink %s.", IRM_SOCK_PATH); - - pthread_rwlock_wrlock(&irmd.flows_lock); - - if (irmd.port_ids != NULL) - bmp_destroy(irmd.port_ids); - - list_for_each_safe(p, h, &irmd.irm_flows) { - struct irm_flow * f = list_entry(p, struct irm_flow, next); - list_del(&f->next); - irm_flow_destroy(f); - } - - pthread_rwlock_unlock(&irmd.flows_lock); - pthread_rwlock_wrlock(&irmd.reg_lock); + /* Clear the lists. */ list_for_each_safe(p, h, &irmd.ipcps) { struct ipcp_entry * e = list_entry(p, struct ipcp_entry, next); @@ -1622,6 +1605,25 @@ static void irm_fini(void) pthread_rwlock_unlock(&irmd.reg_lock); + close(irmd.sockfd); + + if (unlink(IRM_SOCK_PATH)) + log_dbg("Failed to unlink %s.", IRM_SOCK_PATH); + + pthread_rwlock_wrlock(&irmd.flows_lock); + + if (irmd.port_ids != NULL) + bmp_destroy(irmd.port_ids); + + list_for_each_safe(p, h, &irmd.irm_flows) { + struct irm_flow * f = list_entry(p, struct irm_flow, next); + list_del(&f->next); + irm_flow_destroy(f); + } + + pthread_rwlock_unlock(&irmd.flows_lock); + + if (irmd.rdrb != NULL) shm_rdrbuff_destroy(irmd.rdrb); -- cgit v1.2.3