summaryrefslogtreecommitdiff
path: root/src/irmd/irm_flow.c
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@ugent.be>2017-03-30 20:33:22 +0200
committerdimitri staessens <dimitri.staessens@ugent.be>2017-03-31 11:51:33 +0200
commit7ba0fd0ce19244745c8d2512ce8a003783d914a7 (patch)
treee33ed7dae832ef96cd1997ec038764fac5d95d4c /src/irmd/irm_flow.c
parentbce97d70ce43290f8351f34c763b30bfd73e6b99 (diff)
downloadouroboros-7ba0fd0ce19244745c8d2512ce8a003783d914a7.tar.gz
ouroboros-7ba0fd0ce19244745c8d2512ce8a003783d914a7.zip
lib: Revise flow allocation API
The flow_alloc_res and flow_alloc_resp calls have been removed. The flow_alloc and flow_accept calls are now both blocking and take an additional timeout argument.
Diffstat (limited to 'src/irmd/irm_flow.c')
-rw-r--r--src/irmd/irm_flow.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/irmd/irm_flow.c b/src/irmd/irm_flow.c
index 99966561..4e7c22ef 100644
--- a/src/irmd/irm_flow.c
+++ b/src/irmd/irm_flow.c
@@ -45,6 +45,7 @@ struct irm_flow * irm_flow_create(pid_t n_api,
}
if (pthread_mutex_init(&f->state_lock, NULL)) {
+ pthread_cond_destroy(&f->state_cond);
free(f);
return NULL;
}
@@ -63,6 +64,9 @@ struct irm_flow * irm_flow_create(pid_t n_api,
f->n_1_rb = shm_rbuff_create(n_1_api, port_id);
if (f->n_1_rb == NULL) {
log_err("Could not create ringbuffer for AP-I %d.", n_1_api);
+ shm_rbuff_destroy(f->n_rb);
+ pthread_mutex_destroy(&f->state_lock);
+ pthread_cond_destroy(&f->state_cond);
free(f);
return NULL;
}
@@ -122,7 +126,8 @@ enum flow_state irm_flow_get_state(struct irm_flow * f)
return state;
}
-void irm_flow_set_state(struct irm_flow * f, enum flow_state state)
+void irm_flow_set_state(struct irm_flow * f,
+ enum flow_state state)
{
assert(f);
assert(state != FLOW_DESTROY);
@@ -135,7 +140,8 @@ void irm_flow_set_state(struct irm_flow * f, enum flow_state state)
pthread_mutex_unlock(&f->state_lock);
}
-enum flow_state irm_flow_wait_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);
@@ -143,6 +149,8 @@ enum flow_state irm_flow_wait_state(struct irm_flow * f, enum flow_state state)
pthread_mutex_lock(&f->state_lock);
+ assert(f->state != FLOW_NULL);
+
while (!(f->state == state || f->state == FLOW_DESTROY))
pthread_cond_wait(&f->state_cond, &f->state_lock);