summaryrefslogtreecommitdiffstats
path: root/src/plugins/hs_apps/sapi
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/hs_apps/sapi')
-rw-r--r--src/plugins/hs_apps/sapi/vpp_echo.c25
-rw-r--r--src/plugins/hs_apps/sapi/vpp_echo_bapi.c2
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;