diff options
author | Dimitri Staessens <[email protected]> | 2018-04-25 20:26:29 +0200 |
---|---|---|
committer | Sander Vrijders <[email protected]> | 2018-04-26 09:56:06 +0200 |
commit | 639a17a3ac9236494b814e51a34583b4dccd754c (patch) | |
tree | c357a3f3f630bf036ed9cbe1fa0c2350b6dcbc5a | |
parent | df210e9e10cf7cd036954a7e772552fdbf715f83 (diff) | |
download | ouroboros-639a17a3ac9236494b814e51a34583b4dccd754c.tar.gz ouroboros-639a17a3ac9236494b814e51a34583b4dccd754c.zip |
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 <[email protected]>
Signed-off-by: Sander Vrijders <[email protected]>
-rw-r--r-- | src/irmd/main.c | 38 |
1 files 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); |