diff options
author | Sander Vrijders <sander.vrijders@intec.ugent.be> | 2016-06-18 20:59:30 +0200 |
---|---|---|
committer | Sander Vrijders <sander.vrijders@intec.ugent.be> | 2016-06-18 20:59:30 +0200 |
commit | bdb4cb8b8f65336d2573476639ba7d79ec924130 (patch) | |
tree | 55898ed870bd8c256e6b0b9e00d529c781dd1fa2 /src | |
parent | 7a12dc9d5841bb880f4bb79dbbd5e09dcb79ef98 (diff) | |
parent | 8014e2812db53027681c6ca1aa3adee83368cb0d (diff) | |
download | ouroboros-bdb4cb8b8f65336d2573476639ba7d79ec924130.tar.gz ouroboros-bdb4cb8b8f65336d2573476639ba7d79ec924130.zip |
Merged in dstaesse/ouroboros/be-cleanup-flows (pull request #130)
irmd: cleanup of flows
Diffstat (limited to 'src')
-rw-r--r-- | src/irmd/main.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/irmd/main.c b/src/irmd/main.c index 87625205..3221edee 100644 --- a/src/irmd/main.c +++ b/src/irmd/main.c @@ -1353,6 +1353,7 @@ void * irm_flow_cleaner() LOG_WARN("Failed to get time."); /* cleanup stale PENDING flows */ rw_lock_rdlock(&instance->state_lock); + rw_lock_wrlock(&instance->flows_lock); list_for_each_safe(pos, n, &(instance->port_map)) { struct port_map_entry * e = @@ -1362,15 +1363,24 @@ void * irm_flow_cleaner() if (e->state == FLOW_PENDING && ts_diff_ms(&e->t0, &now) > IRMD_FLOW_TIMEOUT) { - LOG_DBGF("Flow time exceeded on port ID %d.", + LOG_DBGF("Pending port_id %d timed out.", e->port_id); e->state = FLOW_NULL; pthread_cond_broadcast(&e->res_signal); } + if (kill(e->n_pid, 0) < 0 || kill(e->n_1_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); + free(e); + } + pthread_mutex_unlock(&e->res_lock); } + rw_lock_unlock(&instance->flows_lock); rw_lock_unlock(&instance->state_lock); nanosleep(&timeout, NULL); |