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 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/plugins/hs_apps/sapi/vpp_echo.c') 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)); -- cgit 1.2.3-korg