summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@ugent.be>2017-04-04 20:24:13 +0200
committerdimitri staessens <dimitri.staessens@ugent.be>2017-04-04 21:18:09 +0200
commit8a2fd3b8efc2de080349c4ab50a314748adc2699 (patch)
tree0f156ba97df948f3f3f9d7b32fc2188e93a56e43 /src
parent9ac91c79e815126aac17891385e0012078e7a88f (diff)
downloadouroboros-8a2fd3b8efc2de080349c4ab50a314748adc2699.tar.gz
ouroboros-8a2fd3b8efc2de080349c4ab50a314748adc2699.zip
lib: Fix insertion in lockless rbuff
Diffstat (limited to 'src')
-rw-r--r--src/lib/shm_rbuff_ll.c4
1 files changed, 2 insertions, 2 deletions
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);