From 42b32c6e6abae77c12411485b3ad2cc207065611 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Thu, 5 Apr 2012 13:00:32 -0400 Subject: [PATCH] ck_ring: Apply ck_ring_size logic to ck_ring_enqueue functions. This bug fix was contributed by Matt Johnson . --- include/ck_ring.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/ck_ring.h b/include/ck_ring.h index 3a386ff..f4cce7a 100644 --- a/include/ck_ring.h +++ b/include/ck_ring.h @@ -85,7 +85,7 @@ producer = ck_pr_load_uint(&ring->p_tail); \ size = ck_pr_load_uint(&ring->size); \ \ - if (producer - consumer == size - 1) \ + if (((producer + 1) & ring->mask) == consumer) \ return (false); \ \ ring->ring[producer] = *entry; \ @@ -167,7 +167,7 @@ ck_ring_enqueue_spsc(struct ck_ring *ring, void *entry) producer = ck_pr_load_uint(&ring->p_tail); size = ck_pr_load_uint(&ring->size); - if (producer - consumer == size - 1) + if (((producer + 1) & ring->mask) == consumer) return (false); ck_pr_store_ptr(&ring->ring[producer], entry);