From: Florin Coras Date: Wed, 21 Jul 2021 04:12:23 +0000 (-0700) Subject: hsa: separate ctrl and test session accept vcl server X-Git-Tag: v22.02-rc0~182 X-Git-Url: https://gerrit.fd.io/r/gitweb?a=commitdiff_plain;h=e71aeab3926485ee42d185483f8fe5bffe4693bf;p=vpp.git hsa: separate ctrl and test session accept vcl server Type: improvement Signed-off-by: Florin Coras Change-Id: Id6bcf6511c904c8625c0845cd9758539f35e6b50 --- diff --git a/src/plugins/hs_apps/vcl/vcl_test_server.c b/src/plugins/hs_apps/vcl/vcl_test_server.c index 78d7752dd68..93c244484c8 100644 --- a/src/plugins/hs_apps/vcl/vcl_test_server.c +++ b/src/plugins/hs_apps/vcl/vcl_test_server.c @@ -306,6 +306,48 @@ vts_server_echo (vcl_test_session_t *conn, int rx_bytes) vtinf ("(fd %d): TX (%d bytes) - '%s'", conn->fd, tx_bytes, conn->rxbuf); } +static vcl_test_session_t * +vts_accept_ctrl (vcl_test_server_worker_t *wrk, int listen_fd) +{ + vcl_test_server_main_t *vsm = &vcl_server_main; + const vcl_test_proto_vft_t *tp; + vcl_test_session_t *conn; + struct epoll_event ev; + int rv; + + conn = conn_pool_alloc (wrk); + if (!conn) + { + vtwrn ("No free connections!"); + return 0; + } + + if (vsm->ctrl) + conn->cfg = vsm->ctrl->cfg; + vcl_test_session_buf_alloc (conn); + clock_gettime (CLOCK_REALTIME, &conn->old_stats.stop); + + tp = vcl_test_main.protos[VPPCOM_PROTO_TCP]; + if (tp->accept (listen_fd, conn)) + return 0; + + vtinf ("CTRL accepted fd = %d (0x%08x) on listener fd = %d (0x%08x)", + conn->fd, conn->fd, listen_fd, listen_fd); + + ev.events = EPOLLET | EPOLLIN; + ev.data.u64 = conn - wrk->conn_pool; + rv = vppcom_epoll_ctl (wrk->epfd, EPOLL_CTL_ADD, conn->fd, &ev); + if (rv < 0) + { + vterr ("vppcom_epoll_ctl()", rv); + return 0; + } + + wrk->nfds++; + + return conn; +} + static vcl_test_session_t * vts_accept_client (vcl_test_server_worker_t *wrk, int listen_fd) { @@ -654,7 +696,7 @@ vts_worker_loop (void *arg) vtwrn ("ctrl already exists"); continue; } - vsm->ctrl = vts_accept_client (wrk, vsm->ctrl_listen_fd); + vsm->ctrl = vts_accept_ctrl (wrk, vsm->ctrl_listen_fd); continue; } if (ep_evts[i].data.u32 == VCL_TEST_DATA_LISTENER)