-static int
-vppcom_session_disconnect (u32 session_handle)
-{
- vcl_worker_t *wrk = vcl_worker_get_current ();
- svm_msg_q_t *vpp_evt_q;
- vcl_session_t *session, *listen_session;
- vcl_session_state_t state;
- u64 vpp_handle;
-
- session = vcl_session_get_w_handle (wrk, session_handle);
- if (!session)
- return VPPCOM_EBADFD;
-
- vpp_handle = session->vpp_handle;
- state = session->session_state;
-
- VDBG (1, "session %u [0x%llx] state 0x%x (%s)", session->session_index,
- vpp_handle, state, vppcom_session_state_str (state));
-
- if (PREDICT_FALSE (state == VCL_STATE_LISTEN))
- {
- VDBG (0, "ERROR: Cannot disconnect a listen socket!");
- return VPPCOM_EBADFD;
- }
-
- if (state == VCL_STATE_VPP_CLOSING)
- {
- vpp_evt_q = vcl_session_vpp_evt_q (wrk, session);
- vcl_send_session_disconnected_reply (vpp_evt_q, wrk->api_client_handle,
- vpp_handle, 0);
- VDBG (1, "session %u [0x%llx]: sending disconnect REPLY...",
- session->session_index, vpp_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);
- }
-
- if (session->listener_index != VCL_INVALID_SESSION_INDEX)
- {
- listen_session = vcl_session_get (wrk, session->listener_index);
- listen_session->n_accepted_sessions--;
- }
-
- return VPPCOM_OK;
-}
-