summaryrefslogtreecommitdiffstats
path: root/src/svm/svm_fifo.c
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2019-05-03 11:46:55 -0700
committerFlorin Coras <florin.coras@gmail.com>2019-05-03 20:27:45 +0000
commit344ce4277885e448912fdfc35bcfaf130c74d086 (patch)
treee2ecaf3ad0c4ca224a32815af44ffd781bcfae5d /src/svm/svm_fifo.c
parenta7570b0378b071129937a89a5632011a962cdb43 (diff)
session/svm: apis for fifo shrinking
Change-Id: Ie519683bb90aae6fb95f2a09e251cded1890ed41 Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/svm/svm_fifo.c')
-rw-r--r--src/svm/svm_fifo.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/svm/svm_fifo.c b/src/svm/svm_fifo.c
index e017b619d15..3824d998866 100644
--- a/src/svm/svm_fifo.c
+++ b/src/svm/svm_fifo.c
@@ -677,7 +677,10 @@ svm_fifo_reduce_size (svm_fifo_t * f, u32 len, u8 try_shrink)
svm_fifo_chunk_t *cur;
u32 actual_len = 0;
- if (len > f->nitems)
+ /* Abort if trying to reduce by more than fifo size or if
+ * fifo is undergoing resizing already */
+ if (len >= f->size || f->size > f->nitems + 1
+ || (f->flags & SVM_FIFO_F_SHRINK) || (f->flags & SVM_FIFO_F_GROW))
return 0;
/* last chunk that will not be removed */