diff options
| author | dimitri staessens <dimitri.staessens@intec.ugent.be> | 2016-06-18 15:44:17 +0200 | 
|---|---|---|
| committer | dimitri staessens <dimitri.staessens@intec.ugent.be> | 2016-06-18 20:01:52 +0200 | 
| commit | 8014e2812db53027681c6ca1aa3adee83368cb0d (patch) | |
| tree | 55898ed870bd8c256e6b0b9e00d529c781dd1fa2 /src/irmd | |
| parent | 7a12dc9d5841bb880f4bb79dbbd5e09dcb79ef98 (diff) | |
| download | ouroboros-8014e2812db53027681c6ca1aa3adee83368cb0d.tar.gz ouroboros-8014e2812db53027681c6ca1aa3adee83368cb0d.zip | |
irmd: cleanup of flows
Port_id's on pending flows that time out are now released.  Flows that
are stale because one of the parent processes exited are removed.
Diffstat (limited to 'src/irmd')
| -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); | 
