summaryrefslogtreecommitdiffstats
path: root/src/vcl/vcl_test.h
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2018-09-11 16:33:36 -0700
committerMarco Varlese <marco.varlese@suse.de>2018-09-12 09:13:16 +0000
commit2cba8533cc4444c4615903add9a8f20c7c87079c (patch)
tree3a35e400cd081c34ae5801d71f5fec51c02611df /src/vcl/vcl_test.h
parent41c9e04be0ca3a081926045e78dc969dab563532 (diff)
vcl: add apis that expos fifo as buffer
Change-Id: I4bd9c9f73499711e04b38d53daa5c917a4285bf5 Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vcl/vcl_test.h')
-rw-r--r--src/vcl/vcl_test.h42
1 files changed, 37 insertions, 5 deletions
diff --git a/src/vcl/vcl_test.h b/src/vcl/vcl_test.h
index 8808c0f5c5e..83e63e1a4e7 100644
--- a/src/vcl/vcl_test.h
+++ b/src/vcl/vcl_test.h
@@ -77,11 +77,43 @@ vcl_test_read (int fd, uint8_t *buf, uint32_t nbytes,
if (rx_bytes < 0)
{
- errno_val = errno;
- perror ("ERROR in sock_test_read()");
- fprintf (stderr, "SOCK_TEST: ERROR: socket read "
- "failed (errno = %d)!\n", errno_val);
- errno = errno_val;
+ vterr ("vppcom_session_read()", -errno);
+ }
+ else if (stats)
+ stats->rx_bytes += rx_bytes;
+
+ return (rx_bytes);
+}
+
+static inline int
+vcl_test_read_ds (int fd, vppcom_data_segments_t ds, sock_test_stats_t *stats)
+{
+ int rx_bytes, errno_val;
+
+ do
+ {
+ if (stats)
+ stats->rx_xacts++;
+ rx_bytes = vppcom_session_read_segments (fd, ds);
+
+ if (rx_bytes < 0)
+ {
+ errno = -rx_bytes;
+ rx_bytes = -1;
+ }
+ if (stats)
+ {
+ if ((rx_bytes == 0) ||
+ ((rx_bytes < 0) && ((errno == EAGAIN) || (errno == EWOULDBLOCK))))
+ stats->rx_eagain++;
+ }
+ }
+ while ((rx_bytes == 0) ||
+ ((rx_bytes < 0) && ((errno == EAGAIN) || (errno == EWOULDBLOCK))));
+
+ if (rx_bytes < 0)
+ {
+ vterr ("vppcom_session_read()", -errno);
}
else if (stats)
stats->rx_bytes += rx_bytes;