summaryrefslogtreecommitdiff
path: root/src/irmd
diff options
context:
space:
mode:
authorDimitri Staessens <[email protected]>2018-02-24 20:22:15 +0100
committerSander Vrijders <[email protected]>2018-02-24 20:26:48 +0100
commitf58b017f876ad26ed8e16fac86c6bf09445d65c6 (patch)
treeff5b36fec58a5dc190d8d063cae9ef21841238db /src/irmd
parent1e081ee37c0313656300c92510c701b3079ec09f (diff)
downloadouroboros-f58b017f876ad26ed8e16fac86c6bf09445d65c6.tar.gz
ouroboros-f58b017f876ad26ed8e16fac86c6bf09445d65c6.zip
irmd: Cleanup flow datastructures on exit0.10.3
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 <[email protected]> Signed-off-by: Sander Vrijders <[email protected]>
Diffstat (limited to 'src/irmd')
-rw-r--r--src/irmd/main.c17
1 files changed, 12 insertions, 5 deletions
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);