vcl: avoid multiple reads on peek 21/32621/2
authorFlorin Coras <fcoras@cisco.com>
Fri, 4 Jun 2021 23:28:18 +0000 (16:28 -0700)
committerDave Wallace <dwallacelf@gmail.com>
Mon, 7 Jun 2021 21:31:53 +0000 (21:31 +0000)
Only try once and return what was found.

Type: fix

Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: I50b1d26babf1b7431d36f6b7472a1fb01475bb35
(cherry picked from commit 233683180638d1c7f517b713722cbbeb3b4be86e)

src/vcl/vppcom.c

index ebc9e76..0c6f6e6 100644 (file)
@@ -1987,6 +1987,10 @@ read_again:
     rv = app_recv_stream_raw (rx_fifo, buf, n, 0, peek);
 
   ASSERT (rv >= 0);
+
+  if (peek)
+    return rv;
+
   n_read += rv;
 
   if (svm_fifo_is_empty_cons (rx_fifo))