From 1a15eb7846c97a8b6b22d068eb35d2a3dba150e6 Mon Sep 17 00:00:00 2001 From: Florin Coras Date: Sat, 20 Feb 2021 11:22:07 -0800 Subject: hsa: fifo detach cleanup Type: fix Signed-off-by: Florin Coras Change-Id: I907b2e560d6ecd748aa7c6d775c4f7122a39b4cb --- src/plugins/hs_apps/sapi/vpp_echo.c | 25 +++++++++++++++++++++++++ src/plugins/hs_apps/sapi/vpp_echo_bapi.c | 2 ++ 2 files changed, 27 insertions(+) (limited to 'src') diff --git a/src/plugins/hs_apps/sapi/vpp_echo.c b/src/plugins/hs_apps/sapi/vpp_echo.c index 816b7d41c77..d78bd12f96c 100644 --- a/src/plugins/hs_apps/sapi/vpp_echo.c +++ b/src/plugins/hs_apps/sapi/vpp_echo.c @@ -255,6 +255,30 @@ echo_update_count_on_session_close (echo_main_t * em, echo_session_t * s) echo_notify_event (em, ECHO_EVT_LAST_BYTE); } +static void +echo_session_detach_fifos (echo_session_t *s) +{ + echo_main_t *em = &echo_main; + fifo_segment_t *fs; + + if (!s->rx_fifo) + return; + + clib_spinlock_lock (&em->segment_handles_lock); + + fs = fifo_segment_get_segment_if_valid (&em->segment_main, + s->rx_fifo->segment_index); + + if (!fs) + goto done; + + fifo_segment_free_client_fifo (fs, s->rx_fifo); + fifo_segment_free_client_fifo (fs, s->tx_fifo); + +done: + clib_spinlock_unlock (&em->segment_handles_lock); +} + static void echo_free_sessions (echo_main_t * em) { @@ -273,6 +297,7 @@ echo_free_sessions (echo_main_t * em) { /* Free session */ s = pool_elt_at_index (em->sessions, *session_index); + echo_session_detach_fifos (s); echo_session_handle_add_del (em, s->vpp_session_handle, SESSION_INVALID_INDEX); clib_memset (s, 0xfe, sizeof (*s)); diff --git a/src/plugins/hs_apps/sapi/vpp_echo_bapi.c b/src/plugins/hs_apps/sapi/vpp_echo_bapi.c index 915448a0be4..0a0168b070e 100644 --- a/src/plugins/hs_apps/sapi/vpp_echo_bapi.c +++ b/src/plugins/hs_apps/sapi/vpp_echo_bapi.c @@ -289,6 +289,8 @@ echo_attach_session (uword segment_handle, uword rxf_offset, uword txf_offset, fs = fifo_segment_get_segment (&em->segment_main, fs_index); s->rx_fifo = fifo_segment_alloc_fifo_w_offset (fs, rxf_offset); s->tx_fifo = fifo_segment_alloc_fifo_w_offset (fs, txf_offset); + s->rx_fifo->segment_index = fs_index; + s->tx_fifo->segment_index = fs_index; s->rx_fifo->shr->client_session_index = s->session_index; s->tx_fifo->shr->client_session_index = s->session_index; -- cgit 1.2.3-korg