summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@intec.ugent.be>2016-10-27 14:04:12 +0000
committerSander Vrijders <sander.vrijders@intec.ugent.be>2016-10-27 14:04:12 +0000
commit98f6ab88208a71fb0eed578f0a9a87d578c44f93 (patch)
treecdb3625d3c858d08bbccd4a69881933712b5f464 /src
parent6c2164a59ce4d3ed91a65326ac89bb247e9f622f (diff)
parent5e8400b3b148d78861152bd551800b1e93a58155 (diff)
downloadouroboros-98f6ab88208a71fb0eed578f0a9a87d578c44f93.tar.gz
ouroboros-98f6ab88208a71fb0eed578f0a9a87d578c44f93.zip
Merged in dstaesse/ouroboros/be-irmd (pull request #288)
irmd: Fix cleanup of pending flows
Diffstat (limited to 'src')
-rw-r--r--src/irmd/irm_flow.c13
-rw-r--r--src/irmd/main.c9
2 files changed, 19 insertions, 3 deletions
diff --git a/src/irmd/irm_flow.c b/src/irmd/irm_flow.c
index dc5d22d8..ac854832 100644
--- a/src/irmd/irm_flow.c
+++ b/src/irmd/irm_flow.c
@@ -26,6 +26,7 @@
#include <stdlib.h>
#include <stdbool.h>
+#include <assert.h>
struct irm_flow * irm_flow_create()
{
@@ -59,6 +60,8 @@ struct irm_flow * irm_flow_create()
void irm_flow_destroy(struct irm_flow * f)
{
+ assert(f);
+
pthread_mutex_lock(&f->state_lock);
if (f->state == FLOW_DESTROY) {
@@ -91,6 +94,8 @@ enum flow_state irm_flow_get_state(struct irm_flow * f)
{
enum flow_state state;
+ assert(f);
+
pthread_mutex_lock(&f->state_lock);
state = f->state;
@@ -102,6 +107,10 @@ enum flow_state irm_flow_get_state(struct irm_flow * f)
void irm_flow_set_state(struct irm_flow * f, enum flow_state state)
{
+ assert(f);
+ assert(state != FLOW_NULL);
+ assert(state != FLOW_DESTROY);
+
pthread_mutex_lock(&f->state_lock);
f->state = state;
@@ -112,6 +121,10 @@ void irm_flow_set_state(struct irm_flow * f, enum flow_state state)
enum flow_state irm_flow_wait_state(struct irm_flow * f, enum flow_state state)
{
+ assert(f);
+ assert(state != FLOW_NULL);
+ assert(state != FLOW_DESTROY);
+
pthread_mutex_lock(&f->state_lock);
while (!(f->state == state || f->state == FLOW_DESTROY))
diff --git a/src/irmd/main.c b/src/irmd/main.c
index 548ab1db..2bb933c4 100644
--- a/src/irmd/main.c
+++ b/src/irmd/main.c
@@ -1750,16 +1750,19 @@ void * irm_sanitize(void * o)
if (irm_flow_get_state(f) == FLOW_ALLOC_PENDING
&& ts_diff_ms(&f->t0, &now) > IRMD_FLOW_TIMEOUT) {
- LOG_INFO("Pending port_id %d timed out.",
+ bmp_release(irmd->port_ids, f->port_id);
+ list_del(&f->next);
+ LOG_DBG("Pending port_id %d timed out.",
f->port_id);
- irm_flow_set_state(f, FLOW_NULL);
+ ipcp_flow_dealloc(f->n_1_api, f->port_id);
+ irm_flow_destroy(f);
continue;
}
if (kill(f->n_api, 0) < 0) {
bmp_release(irmd->port_ids, f->port_id);
list_del(&f->next);
- LOG_INFO("AP-I %d gone, flow %d deallocated.",
+ LOG_DBG("AP-I %d gone, flow %d deallocated.",
f->n_api, f->port_id);
ipcp_flow_dealloc(f->n_1_api, f->port_id);
irm_flow_destroy(f);