summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSander Vrijders <[email protected]>2016-06-18 20:59:30 +0200
committerSander Vrijders <[email protected]>2016-06-18 20:59:30 +0200
commitbdb4cb8b8f65336d2573476639ba7d79ec924130 (patch)
tree55898ed870bd8c256e6b0b9e00d529c781dd1fa2
parent7a12dc9d5841bb880f4bb79dbbd5e09dcb79ef98 (diff)
parent8014e2812db53027681c6ca1aa3adee83368cb0d (diff)
downloadouroboros-bdb4cb8b8f65336d2573476639ba7d79ec924130.tar.gz
ouroboros-bdb4cb8b8f65336d2573476639ba7d79ec924130.zip
Merged in dstaesse/ouroboros/be-cleanup-flows (pull request #130)
irmd: cleanup of flows
-rw-r--r--src/irmd/main.c12
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);