summaryrefslogtreecommitdiff
path: root/src/lib/shm_rbuff.c
diff options
context:
space:
mode:
authorSander Vrijders <[email protected]>2016-12-12 15:20:07 +0100
committerSander Vrijders <[email protected]>2016-12-12 15:20:07 +0100
commitfc8d30f2d6e9f3e463aff81a1630ff56f9463a22 (patch)
treed91c005451a74822516669f3f7cc3ade34971abb /src/lib/shm_rbuff.c
parented6ac5db8474edabe83f0cdcbe7f258f0859ea41 (diff)
parentf8c14e0246a6c9cb5e8ff47869b5968abb63f010 (diff)
downloadouroboros-fc8d30f2d6e9f3e463aff81a1630ff56f9463a22.tar.gz
ouroboros-fc8d30f2d6e9f3e463aff81a1630ff56f9463a22.zip
Merged in dstaesse/ouroboros/be-timeout (pull request #323)
Be timeout
Diffstat (limited to 'src/lib/shm_rbuff.c')
-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) {