From a2127552f32b8d9a4c9a988547b4eaa8e1b4a5ca Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Sun, 19 Jun 2016 12:26:13 +0200 Subject: irmd: improved cleanup of flows If the AP exits, the IRMd will deallocate the flow. If an IPCP dies, the IRMd will remove the stale resources. --- src/irmd/main.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/irmd/main.c b/src/irmd/main.c index 3221edee..bf46a2fd 100644 --- a/src/irmd/main.c +++ b/src/irmd/main.c @@ -1059,6 +1059,7 @@ static int flow_alloc_res(int port_id) return 0; } if (e->state == FLOW_NULL) { + /* don't release the port_id, AP has to call dealloc */ list_del(&e->next); rw_lock_unlock(&instance->flows_lock); rw_lock_unlock(&instance->state_lock); @@ -1369,11 +1370,20 @@ void * irm_flow_cleaner() pthread_cond_broadcast(&e->res_signal); } - if (kill(e->n_pid, 0) < 0 || kill(e->n_1_pid, 0) < 0) { + + if (kill(e->n_pid, 0) < 0) { bmp_release(instance->port_ids, e->port_id); + list_del(&e->next); - LOG_DBGF("Process died, port_id %d removed.", - e->port_id); + LOG_DBGF("Process %d gone, %d deallocated.", + e->n_pid, e->port_id); + ipcp_flow_dealloc(e->n_1_pid, e->port_id); + free(e); + } + if (kill(e->n_1_pid, 0) < 0) { + list_del(&e->next); + LOG_ERR("IPCP %d gone, flow %d removed.", + e->n_1_pid, e->port_id); free(e); } @@ -1575,7 +1585,7 @@ static struct irm * irm_create() shm_du_map_destroy(dum); LOG_INFO("Stale shm file removed."); } else { - LOG_WARN("IRMd already running, exiting."); + LOG_INFO("IRMd already running, exiting."); free(i); exit(EXIT_SUCCESS); } -- cgit v1.2.3