From 8a2fd3b8efc2de080349c4ab50a314748adc2699 Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Tue, 4 Apr 2017 20:24:13 +0200 Subject: lib: Fix insertion in lockless rbuff --- src/lib/shm_rbuff_ll.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/lib') diff --git a/src/lib/shm_rbuff_ll.c b/src/lib/shm_rbuff_ll.c index d777de8b..1e072b21 100644 --- a/src/lib/shm_rbuff_ll.c +++ b/src/lib/shm_rbuff_ll.c @@ -244,14 +244,14 @@ int shm_rbuff_write(struct shm_rbuff * rb, nhead = RB_HEAD; + *(rb->shm_base + nhead) = (ssize_t) idx; + do { ohead = nhead; nhead = (ohead + 1) & ((SHM_BUFFER_SIZE) - 1); nhead = __sync_val_compare_and_swap(rb->head, ohead, nhead); } while (nhead != ohead); - *(rb->shm_base + nhead) = (ssize_t) idx; - if (was_empty) pthread_cond_broadcast(rb->add); -- cgit v1.2.3