[PATCH v3] lib: Fix blocking writes to smaller rbuff

  • From: Dimitri Staessens <dimitri@ouroboros.rocks>
  • To: ouroboros@xxxxxxxxxxxxx
  • Date: Wed, 17 Apr 2019 19:57:25 +0200

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>
---
 src/lib/shm_rbuff_pthr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/lib/shm_rbuff_pthr.c b/src/lib/shm_rbuff_pthr.c
index 5a58605..12d2810 100644
--- a/src/lib/shm_rbuff_pthr.c
+++ b/src/lib/shm_rbuff_pthr.c
@@ -111,11 +111,11 @@ 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);
-- 
2.21.0


Other related posts: