diff options
author | Florin Coras <fcoras@cisco.com> | 2021-02-20 11:22:07 -0800 |
---|---|---|
committer | Dave Barach <openvpp@barachs.net> | 2021-02-23 21:11:21 +0000 |
commit | 1a15eb7846c97a8b6b22d068eb35d2a3dba150e6 (patch) | |
tree | 2f3a9d3b1185dad7a0f35b5c6c2786266aed9942 /src/plugins/hs_apps/sapi | |
parent | 4c6bbd7a9b2232324e8509ac22a5321e302dd3e3 (diff) |
hsa: fifo detach cleanup
Type: fix
Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: I907b2e560d6ecd748aa7c6d775c4f7122a39b4cb
Diffstat (limited to 'src/plugins/hs_apps/sapi')
-rw-r--r-- | src/plugins/hs_apps/sapi/vpp_echo.c | 25 | ||||
-rw-r--r-- | src/plugins/hs_apps/sapi/vpp_echo_bapi.c | 2 |
2 files changed, 27 insertions, 0 deletions
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 @@ -256,6 +256,30 @@ echo_update_count_on_session_close (echo_main_t * em, echo_session_t * s) } 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) { /* Free marked sessions */ @@ -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; |