summaryrefslogtreecommitdiff
path: root/src/lib/shm_flow_set.c
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@intec.ugent.be>2016-10-30 10:36:08 +0100
committerdimitri staessens <dimitri.staessens@intec.ugent.be>2016-10-30 10:36:08 +0100
commit5d01776443c0a500ffbc79a36745b07b8628bd62 (patch)
tree60117ebc2d1612d503c8d1e26630a08fc67b17ef /src/lib/shm_flow_set.c
parent298f78d426cdf8bcd9c8890f117d0236bde20bc4 (diff)
downloadouroboros-5d01776443c0a500ffbc79a36745b07b8628bd62.tar.gz
ouroboros-5d01776443c0a500ffbc79a36745b07b8628bd62.zip
lib: Have flow_event_wait return non-zero value
Flow_event_wait will either return -EINVAL, -ETIMEDOUT or a positive integer indicating the number of SDUs in the fqueue. This allows to call the function as the condition for a non-terminating while loop.
Diffstat (limited to 'src/lib/shm_flow_set.c')
-rw-r--r--src/lib/shm_flow_set.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/lib/shm_flow_set.c b/src/lib/shm_flow_set.c
index 3b1af83f..6cc94573 100644
--- a/src/lib/shm_flow_set.c
+++ b/src/lib/shm_flow_set.c
@@ -376,22 +376,20 @@ ssize_t shm_flow_set_wait(const struct shm_flow_set * shm_set,
while (shm_set->heads[idx] == 0 && ret != -ETIMEDOUT) {
if (timeout != NULL)
- ret = pthread_cond_timedwait(shm_set->conds + idx,
- shm_set->lock,
- &abstime);
+ ret = -pthread_cond_timedwait(shm_set->conds + idx,
+ shm_set->lock,
+ &abstime);
else
- ret = pthread_cond_wait(shm_set->conds + idx,
- shm_set->lock);
+ ret = -pthread_cond_wait(shm_set->conds + idx,
+ shm_set->lock);
#ifndef __APPLE__
- if (ret == EOWNERDEAD) {
+ if (ret == -EOWNERDEAD) {
LOG_DBG("Recovering dead mutex.");
pthread_mutex_consistent(shm_set->lock);
}
#endif
- if (ret == ETIMEDOUT) {
- ret = -ETIMEDOUT;
+ if (ret == -ETIMEDOUT)
break;
- }
}
if (ret != -ETIMEDOUT) {
@@ -404,5 +402,7 @@ ssize_t shm_flow_set_wait(const struct shm_flow_set * shm_set,
pthread_cleanup_pop(true);
+ assert(ret);
+
return ret;
}