summaryrefslogtreecommitdiff
path: root/src/lib/shm_rbuff_pthr.c
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2019-04-17 20:00:56 +0200
committerSander Vrijders <sander@ouroboros.rocks>2019-04-17 20:41:07 +0200
commit6a81bd8a4df688f397a8b218f326f4e5ce71f6cd (patch)
tree4ec484c11d2ceb9a54055c125403d8f04c5395fa /src/lib/shm_rbuff_pthr.c
parentedd2c555ed952a5c97da99c4d63c6a9c954b54c6 (diff)
downloadouroboros-6a81bd8a4df688f397a8b218f326f4e5ce71f6cd.tar.gz
ouroboros-6a81bd8a4df688f397a8b218f326f4e5ce71f6cd.zip
lib: Fix blocking writes to smaller rbuff
This fixes writing at high speeds when the rbuff is smaller than the rdrbuff. The pthread_cond_wait calls were blocking on the wrong condition variable. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'src/lib/shm_rbuff_pthr.c')
-rw-r--r--src/lib/shm_rbuff_pthr.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/lib/shm_rbuff_pthr.c b/src/lib/shm_rbuff_pthr.c
index 5a58605b..7e549121 100644
--- a/src/lib/shm_rbuff_pthr.c
+++ b/src/lib/shm_rbuff_pthr.c
@@ -111,21 +111,20 @@ int shm_rbuff_write_b(struct shm_rbuff * rb,
while (!shm_rbuff_free(rb) && ret != -ETIMEDOUT) {
if (abstime != NULL)
- ret = -pthread_cond_timedwait(rb->add,
+ ret = -pthread_cond_timedwait(rb->del,
rb->lock,
abstime);
else
- ret = -pthread_cond_wait(rb->add, rb->lock);
+ ret = -pthread_cond_wait(rb->del, rb->lock);
#ifdef HAVE_ROBUST_MUTEX
if (ret == -EOWNERDEAD)
pthread_mutex_consistent(rb->lock);
#endif
}
- if (shm_rbuff_empty(rb))
- pthread_cond_broadcast(rb->add);
-
if (ret != -ETIMEDOUT) {
+ if (shm_rbuff_empty(rb))
+ pthread_cond_broadcast(rb->add);
*head_el_ptr(rb) = (ssize_t) idx;
*rb->head = (*rb->head + 1) & ((SHM_RBUFF_SIZE) - 1);
}