vcl: add support to write segments

Type: improvement

Change-Id: Icfdaed6b70b83668127656930afcb4ac3c63b234
Signed-off-by: Aritra Basu <aritrbas@cisco.com>
This commit is contained in:
Aritra Basu
2024-08-27 18:05:17 -07:00
parent e9bc332019
commit f0e81d247b
4 changed files with 106 additions and 5 deletions

View File

@@ -420,6 +420,39 @@ vcl_test_write (vcl_test_session_t *ts, void *buf, uint32_t nbytes)
return (tx_bytes);
}
static inline int
vcl_test_write_ds (vcl_test_session_t *ts)
{
vcl_test_stats_t *stats = &ts->stats;
int tx_bytes;
do
{
stats->tx_xacts++;
if (ts->ds[1].len)
tx_bytes = vppcom_session_write_segments (ts->fd, ts->ds, 2);
else
tx_bytes = vppcom_session_write_segments (ts->fd, ts->ds, 1);
if (tx_bytes < 0)
errno = -tx_bytes;
if ((tx_bytes == 0) ||
((tx_bytes < 0) && ((errno == EAGAIN) || (errno == EWOULDBLOCK))))
stats->rx_eagain++;
}
while ((tx_bytes == 0) ||
((tx_bytes < 0) && ((errno == EAGAIN) || (errno == EWOULDBLOCK))));
if (tx_bytes < 0)
{
vterr ("vppcom_session_write_segments()", -errno);
}
else
stats->tx_bytes += tx_bytes;
return (tx_bytes);
}
static inline void
dump_help (void)
{

View File

@@ -282,11 +282,7 @@ vts_server_process_rx (vcl_test_session_t *conn, int rx_bytes)
if (conn->cfg.test == HS_TEST_TYPE_BI)
{
if (vsm->use_ds)
{
(void) vcl_test_write (conn, conn->ds[0].data, conn->ds[0].len);
if (conn->ds[1].len)
(void) vcl_test_write (conn, conn->ds[1].data, conn->ds[1].len);
}
(void) vcl_test_write_ds (conn);
else
(void) vcl_test_write (conn, conn->rxbuf, rx_bytes);
}