From 6a81bd8a4df688f397a8b218f326f4e5ce71f6cd Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Wed, 17 Apr 2019 20:00:56 +0200 Subject: 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 Signed-off-by: Sander Vrijders --- src/lib/shm_rbuff_pthr.c | 9 ++++----- 1 file 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); } -- cgit v1.2.3