diff options
author | Matus Fabian <matfabia@cisco.com> | 2024-10-24 14:59:56 +0200 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2024-10-25 23:36:06 +0000 |
commit | 26be76cc3ed39391270efba769baac047f8c9acf (patch) | |
tree | 2d61caa9e3bda8f35b1bc8f875607d7e0829a776 /src/plugins | |
parent | 841672258a55defb28b1ca6a35b6ad9830c132cf (diff) |
hsa: http cli client ho session cleanup
Type: improvement
Change-Id: I9266dac18ad3ee57fc8ecca3614b51b2345e9c48
Signed-off-by: Matus Fabian <matfabia@cisco.com>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/hs_apps/http_client_cli.c | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/src/plugins/hs_apps/http_client_cli.c b/src/plugins/hs_apps/http_client_cli.c index 18523de4555..e22e2ba3087 100644 --- a/src/plugins/hs_apps/http_client_cli.c +++ b/src/plugins/hs_apps/http_client_cli.c @@ -98,6 +98,13 @@ hcc_session_get (u32 hs_index, u32 thread_index) return pool_elt_at_index (wrk->sessions, hs_index); } +static void +hcc_ho_session_free (u32 hs_index) +{ + hcc_worker_t *wrk = hcc_worker_get (0); + pool_put_index (wrk->sessions, hs_index); +} + static int hcc_ts_accept_callback (session_t *ts) { @@ -125,9 +132,10 @@ hcc_ts_connected_callback (u32 app_index, u32 hc_index, session_t *as, hcc_worker_t *wrk; http_msg_t msg; u8 *headers_buf; + u32 new_hs_index; int rv; - HCC_DBG ("hc_index: %d", hc_index); + HCC_DBG ("ho hc_index: %d", hc_index); if (err) { @@ -138,19 +146,22 @@ hcc_ts_connected_callback (u32 app_index, u32 hc_index, session_t *as, return -1; } - /* TODO delete half open session once the support is added in http layer */ hs = hcc_session_get (hc_index, 0); wrk = hcc_worker_get (as->thread_index); new_hs = hcc_session_alloc (wrk); + new_hs_index = new_hs->session_index; clib_memcpy_fast (new_hs, hs, sizeof (*hs)); + new_hs->session_index = new_hs_index; + new_hs->thread_index = as->thread_index; + new_hs->vpp_session_index = as->session_index; + HCC_DBG ("new hc_index: %d", new_hs->session_index); + as->opaque = new_hs_index; - hs->vpp_session_index = as->session_index; - - http_add_header (&hs->req_headers, + http_add_header (&new_hs->req_headers, http_header_name_token (HTTP_HEADER_ACCEPT), http_content_type_token (HTTP_CONTENT_TEXT_HTML)); - headers_buf = http_serialize_headers (hs->req_headers); - vec_free (hs->req_headers); + headers_buf = http_serialize_headers (new_hs->req_headers); + vec_free (new_hs->req_headers); msg.type = HTTP_MSG_REQUEST; msg.method_type = HTTP_REQ_GET; @@ -300,6 +311,13 @@ hcc_ts_transport_closed (session_t *s) HCC_TRANSPORT_CLOSED, 0); } +static void +hcc_ho_cleanup_callback (session_t *ts) +{ + HCC_DBG ("ho hc_index: %d:", ts->opaque); + hcc_ho_session_free (ts->opaque); +} + static session_cb_vft_t hcc_session_cb_vft = { .session_accept_callback = hcc_ts_accept_callback, .session_disconnect_callback = hcc_ts_disconnect_callback, @@ -308,6 +326,7 @@ static session_cb_vft_t hcc_session_cb_vft = { .builtin_app_tx_callback = hcc_ts_tx_callback, .session_reset_callback = hcc_ts_reset_callback, .session_transport_closed_callback = hcc_ts_transport_closed, + .half_open_cleanup_callback = hcc_ho_cleanup_callback, }; static clib_error_t * @@ -413,7 +432,7 @@ hcc_run (vlib_main_t *vm, int print_output) hcc_worker_t *wrk; num_threads = 1 /* main thread */ + vtm->n_threads; - vec_validate (hcm->wrk, num_threads); + vec_validate (hcm->wrk, num_threads - 1); vec_foreach (wrk, hcm->wrk) { wrk->thread_index = wrk - hcm->wrk; |