summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@intec.ugent.be>2016-12-12 13:00:43 +0100
committerdimitri staessens <dimitri.staessens@intec.ugent.be>2016-12-12 13:00:43 +0100
commit047052481dc0b47d740b778be239884f2811778c (patch)
treed090a0be61d450306cdd74a4fc3ef0ce44dbaca7 /src/lib
parented6ac5db8474edabe83f0cdcbe7f258f0859ea41 (diff)
downloadouroboros-047052481dc0b47d740b778be239884f2811778c.tar.gz
ouroboros-047052481dc0b47d740b778be239884f2811778c.zip
lib: Simplify shm_rbuff_read_b
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/shm_rbuff.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/lib/shm_rbuff.c b/src/lib/shm_rbuff.c
index 29a62f62..cc64fa09 100644
--- a/src/lib/shm_rbuff.c
+++ b/src/lib/shm_rbuff.c
@@ -287,7 +287,6 @@ ssize_t shm_rbuff_read_b(struct shm_rbuff * rb,
const struct timespec * timeout)
{
struct timespec abstime;
- int ret = 0;
ssize_t idx = -1;
assert(rb);
@@ -299,7 +298,6 @@ ssize_t shm_rbuff_read_b(struct shm_rbuff * rb,
pthread_mutex_consistent(rb->lock);
#endif
if (timeout != NULL) {
- idx = -ETIMEDOUT;
clock_gettime(PTHREAD_COND_CLOCK, &abstime);
ts_add(&abstime, timeout, &abstime);
}
@@ -307,21 +305,17 @@ ssize_t shm_rbuff_read_b(struct shm_rbuff * rb,
pthread_cleanup_push((void(*)(void *))pthread_mutex_unlock,
(void *) rb->lock);
- while (shm_rbuff_empty(rb) && (ret != ETIMEDOUT)) {
+ while (shm_rbuff_empty(rb) && (idx != -ETIMEDOUT)) {
if (timeout != NULL)
- ret = pthread_cond_timedwait(rb->add,
- rb->lock,
- &abstime);
+ idx = -pthread_cond_timedwait(rb->add,
+ rb->lock,
+ &abstime);
else
- ret = pthread_cond_wait(rb->add, rb->lock);
+ idx = -pthread_cond_wait(rb->add, rb->lock);
#ifndef __APPLE__
- if (ret == EOWNERDEAD)
+ if (idx == -EOWNERDEAD)
pthread_mutex_consistent(rb->lock);
#endif
- if (ret == ETIMEDOUT) {
- idx = -ETIMEDOUT;
- break;
- }
}
if (idx != -ETIMEDOUT) {