summaryrefslogtreecommitdiffstats
path: root/extras/libmemif
diff options
context:
space:
mode:
Diffstat (limited to 'extras/libmemif')
-rw-r--r--extras/libmemif/src/main.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/extras/libmemif/src/main.c b/extras/libmemif/src/main.c
index 0644f948c31..0c52169a155 100644
--- a/extras/libmemif/src/main.c
+++ b/extras/libmemif/src/main.c
@@ -2436,7 +2436,7 @@ memif_refill_queue (memif_conn_handle_t conn, uint16_t qid, uint16_t count,
memif_ring_t *ring = mq->ring;
uint16_t mask = (1 << mq->log2_ring_size) - 1;
uint32_t offset_mask = c->run_args.buffer_size - 1;
- uint16_t slot;
+ uint16_t slot, counter = 0;
if (c->args.is_master)
{
@@ -2448,12 +2448,12 @@ memif_refill_queue (memif_conn_handle_t conn, uint16_t qid, uint16_t count,
}
uint16_t head = ring->head;
+ slot = head;
uint16_t ns = (1 << mq->log2_ring_size) - head + mq->last_tail;
- head += (count < ns) ? count : ns;
+ count = (count < ns) ? count : ns;
- slot = ring->head;
memif_desc_t *d;
- while (slot < head)
+ while (counter < count)
{
d = &ring->desc[slot & mask];
d->region = 1;
@@ -2463,10 +2463,11 @@ memif_refill_queue (memif_conn_handle_t conn, uint16_t qid, uint16_t count,
else
d->offset = d->offset - (d->offset & offset_mask) + headroom;
slot++;
+ counter++;
}
MEMIF_MEMORY_BARRIER ();
- ring->head = head;
+ ring->head = slot;
return MEMIF_ERR_SUCCESS; /* 0 */
}