From f58b017f876ad26ed8e16fac86c6bf09445d65c6 Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Sat, 24 Feb 2018 20:22:15 +0100 Subject: irmd: Cleanup flow datastructures on exit The irmd was not cleaning up non-deallocated flows upon exit. This bug was probably introduced with the introduction of the threadpool managers. Also fixes a missing rwlock_destroy(). Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/irmd/main.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/irmd/main.c b/src/irmd/main.c index 64c9efc3..f9cb8fd2 100644 --- a/src/irmd/main.c +++ b/src/irmd/main.c @@ -1555,17 +1555,23 @@ 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); - pthread_rwlock_unlock(&irmd.flows_lock); - - close(irmd.sockfd); + 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); + } - if (unlink(IRM_SOCK_PATH)) - log_dbg("Failed to unlink %s.", IRM_SOCK_PATH); + pthread_rwlock_unlock(&irmd.flows_lock); pthread_rwlock_wrlock(&irmd.reg_lock); /* Clear the lists. */ @@ -1609,6 +1615,7 @@ static void irm_fini(void) pthread_mutex_destroy(&irmd.cmd_lock); pthread_cond_destroy(&irmd.cmd_cond); + pthread_rwlock_destroy(&irmd.flows_lock); pthread_rwlock_destroy(&irmd.reg_lock); pthread_rwlock_destroy(&irmd.state_lock); -- cgit v1.2.3