ck_ring: Apply ck_ring_size logic to ck_ring_enqueue functions.

This bug fix was contributed by Matt Johnson <johnso87@...>.
ck_pring
Samy Al Bahra 13 years ago
parent 706fd07de7
commit 42b32c6e6a

@ -85,7 +85,7 @@
producer = ck_pr_load_uint(&ring->p_tail); \ producer = ck_pr_load_uint(&ring->p_tail); \
size = ck_pr_load_uint(&ring->size); \ size = ck_pr_load_uint(&ring->size); \
\ \
if (producer - consumer == size - 1) \ if (((producer + 1) & ring->mask) == consumer) \
return (false); \ return (false); \
\ \
ring->ring[producer] = *entry; \ 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); producer = ck_pr_load_uint(&ring->p_tail);
size = ck_pr_load_uint(&ring->size); size = ck_pr_load_uint(&ring->size);
if (producer - consumer == size - 1) if (((producer + 1) & ring->mask) == consumer)
return (false); return (false);
ck_pr_store_ptr(&ring->ring[producer], entry); ck_pr_store_ptr(&ring->ring[producer], entry);

Loading…
Cancel
Save