aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2020-08-24 21:23:51 -0700
committerDave Barach <openvpp@barachs.net>2020-08-25 13:39:29 +0000
commita5ea8211b1fba3410eda93fa306cd6987e82dfb5 (patch)
tree251d1d88b1ff8c3bf1914aa57153b514eb21f2b9
parentd0236f725d31e5e5d23e5f207b1a317fcd96a964 (diff)
vcl: cleanup non-blocking connect
Make sure session is in non-closed state after non-blocking connect to ensure cleanup is performed, if needed. Type: fix Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: Ic1533b9864828f875c840dfdfeed08bf32d10651
-rw-r--r--src/vcl/vppcom.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/vcl/vppcom.c b/src/vcl/vppcom.c
index 85d8081aec5..71578b076d2 100644
--- a/src/vcl/vppcom.c
+++ b/src/vcl/vppcom.c
@@ -530,7 +530,13 @@ vcl_session_connected_handler (vcl_worker_t * wrk,
clib_memcpy_fast (&session->transport.lcl_ip, &mp->lcl.ip,
sizeof (session->transport.lcl_ip));
session->transport.lcl_port = mp->lcl.port;
- session->session_state = STATE_CONNECT;
+
+ /* Application closed session before connect reply */
+ if (VCL_SESS_ATTR_TEST (session->attr, VCL_SESS_ATTR_NONBLOCK)
+ && session->session_state == STATE_CLOSED)
+ vcl_send_session_disconnect (wrk, session);
+ else
+ session->session_state = STATE_CONNECT;
/* Add it to lookup table */
vcl_session_table_add_vpp_handle (wrk, mp->handle, session_index);
@@ -1172,6 +1178,11 @@ vppcom_session_disconnect (u32 session_handle)
}
else
{
+ /* Session doesn't have an event queue yet. Probably a non-blocking
+ * connect. Wait for the reply */
+ if (PREDICT_FALSE (!session->vpp_evt_q))
+ return VPPCOM_OK;
+
VDBG (1, "session %u [0x%llx]: sending disconnect...",
session->session_index, vpp_handle);
vcl_send_session_disconnect (wrk, session);
@@ -1788,7 +1799,10 @@ vppcom_session_connect (uint32_t session_handle, vppcom_endpt_t * server_ep)
vcl_send_session_connect (wrk, session);
if (VCL_SESS_ATTR_TEST (session->attr, VCL_SESS_ATTR_NONBLOCK))
- return VPPCOM_EINPROGRESS;
+ {
+ session->session_state = STATE_CONNECT;
+ return VPPCOM_EINPROGRESS;
+ }
/*
* Wait for reply from vpp if blocking