summaryrefslogtreecommitdiff
path: root/src/irmd
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@intec.ugent.be>2016-08-26 16:40:50 +0200
committerdimitri staessens <dimitri.staessens@intec.ugent.be>2016-08-26 16:40:50 +0200
commitdb1fb77187fd9170c9a0a8089225b214053f3034 (patch)
tree58f90407b0a0e3e8e988110b8c2e46efc2f807bc /src/irmd
parentf7777922edd673e43fd670d3d28f052fde2ecc0a (diff)
downloadouroboros-db1fb77187fd9170c9a0a8089225b214053f3034.tar.gz
ouroboros-db1fb77187fd9170c9a0a8089225b214053f3034.zip
irmd: Revise shutdown procedure
Flows are deallocated first, then the socket is closed to prevent IPCPs hanging on the connect.
Diffstat (limited to 'src/irmd')
-rw-r--r--src/irmd/main.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/irmd/main.c b/src/irmd/main.c
index 5f793afd..cd939360 100644
--- a/src/irmd/main.c
+++ b/src/irmd/main.c
@@ -1548,6 +1548,20 @@ static void irm_destroy()
if (irmd->threadpool != NULL)
free(irmd->threadpool);
+ pthread_rwlock_wrlock(&irmd->flows_lock);
+
+ list_for_each_safe(p, h, &irmd->irm_flows) {
+ struct irm_flow * f = list_entry(p, struct irm_flow, next);
+ list_del(&f->next);
+ ipcp_flow_dealloc(f->n_1_api, f->port_id);
+ irm_flow_destroy(f);
+ }
+
+ close(irmd->sockfd);
+
+ if (unlink(IRM_SOCK_PATH))
+ LOG_DBG("Failed to unlink %s.", IRM_SOCK_PATH);
+
pthread_rwlock_wrlock(&irmd->reg_lock);
/* clear the lists */
list_for_each_safe(p, h, &irmd->ipcps) {
@@ -1585,14 +1599,6 @@ static void irm_destroy()
pthread_rwlock_unlock(&irmd->reg_lock);
- pthread_rwlock_wrlock(&irmd->flows_lock);
-
- 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 (irmd->port_ids != NULL)
bmp_destroy(irmd->port_ids);
@@ -1604,11 +1610,6 @@ static void irm_destroy()
if (irmd->lf != NULL)
lockfile_destroy(irmd->lf);
- close(irmd->sockfd);
-
- if (unlink(IRM_SOCK_PATH))
- LOG_DBG("Failed to unlink %s.", IRM_SOCK_PATH);
-
pthread_rwlock_unlock(&irmd->state_lock);
pthread_rwlock_destroy(&irmd->reg_lock);