diff options
author | Florin Coras <fcoras@cisco.com> | 2022-01-18 14:11:11 -0800 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2022-01-19 15:58:20 +0000 |
commit | 95bbbe479eb5179fa61dd691d8d7d726fb71a885 (patch) | |
tree | b7d6a66f291c177ffb65fdbe232d36006c5c586e | |
parent | 017a676654d9cfd9868374b92ff8ac2741ee05f2 (diff) |
svm: fix return for partial segment enqueue
Type: fix
Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: I9953d9bf04e708ac8ea475127e3d2f606cc1c8d9
-rw-r--r-- | src/svm/svm_fifo.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/svm/svm_fifo.c b/src/svm/svm_fifo.c index 2150694ef46..7197e386dbd 100644 --- a/src/svm/svm_fifo.c +++ b/src/svm/svm_fifo.c @@ -1010,25 +1010,26 @@ svm_fifo_enqueue_segments (svm_fifo_t * f, const svm_fifo_seg_t segs[], } else { - len = clib_min (free_count, len); + u32 n_left = clib_min (free_count, len); - if (f_pos_gt (tail + len, f_chunk_end (f_end_cptr (f)))) + if (f_pos_gt (tail + n_left, f_chunk_end (f_end_cptr (f)))) { - if (PREDICT_FALSE (f_try_chunk_alloc (f, head, tail, len))) + if (PREDICT_FALSE (f_try_chunk_alloc (f, head, tail, n_left))) { - len = f_chunk_end (f_end_cptr (f)) - tail; - if (!len) + n_left = f_chunk_end (f_end_cptr (f)) - tail; + if (!n_left) return SVM_FIFO_EGROW; } } + len = n_left; i = 0; - while (len) + while (n_left) { - u32 to_copy = clib_min (segs[i].len, len); + u32 to_copy = clib_min (segs[i].len, n_left); svm_fifo_copy_to_chunk (f, f_tail_cptr (f), tail, segs[i].data, to_copy, &f->shr->tail_chunk); - len -= to_copy; + n_left -= to_copy; tail += to_copy; i++; } |