diff options
author | Florin Coras <fcoras@cisco.com> | 2022-06-03 14:29:20 -0700 |
---|---|---|
committer | Florin Coras <fcoras@cisco.com> | 2022-06-03 15:21:24 -0700 |
commit | db8dd260d5d8ac798a9524f29e746b9094eb73bf (patch) | |
tree | 0fac941af416a0701c5faab1d956338faf81944d /src/plugins | |
parent | 7b8d26c136081563c89e50df3d16a37f2ad3e489 (diff) |
hsa: dealloc proxy fifos on right thread
Type: fix
Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: Ia66c12e1da126d0d8d101b645e6dc8454c3826d6
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/hs_apps/proxy.c | 46 | ||||
-rw-r--r-- | src/plugins/hs_apps/proxy.h | 1 |
2 files changed, 46 insertions, 1 deletions
diff --git a/src/plugins/hs_apps/proxy.c b/src/plugins/hs_apps/proxy.c index db741f3eda1..82d78e4c714 100644 --- a/src/plugins/hs_apps/proxy.c +++ b/src/plugins/hs_apps/proxy.c @@ -105,6 +105,32 @@ proxy_session_free (proxy_session_t *ps) pool_put (pm->sessions, ps); } +static int +proxy_session_postponed_free_rpc (void *arg) +{ + uword ps_index = pointer_to_uword (arg); + proxy_main_t *pm = &proxy_main; + proxy_session_t *ps = 0; + + clib_spinlock_lock_if_init (&pm->sessions_lock); + + ps = proxy_session_get (ps_index); + segment_manager_dealloc_fifos (ps->server_rx_fifo, ps->server_tx_fifo); + proxy_session_free (ps); + + clib_spinlock_unlock_if_init (&pm->sessions_lock); + + return 0; +} + +static void +proxy_session_postponed_free (proxy_session_t *ps) +{ + session_send_rpc_evt_to_thread (ps->po_thread_index, + proxy_session_postponed_free_rpc, + uword_to_pointer (ps->ps_index, void *)); +} + static void proxy_try_close_session (session_t * s, int is_active_open) { @@ -168,8 +194,25 @@ proxy_try_delete_session (session_t * s, u8 is_active_open) { ps->vpp_active_open_handle = SESSION_INVALID_HANDLE; + /* Revert master thread index change on connect notification */ + ps->server_rx_fifo->master_thread_index = ps->po_thread_index; + + /* Passive open already cleaned up */ if (ps->vpp_server_handle == SESSION_INVALID_HANDLE) - proxy_session_free (ps); + { + ASSERT (s->rx_fifo->refcnt == 1); + + /* The two sides of the proxy on different threads */ + if (ps->po_thread_index != s->thread_index) + { + /* This is not the right thread to delete the fifos */ + s->rx_fifo = 0; + s->tx_fifo = 0; + proxy_session_postponed_free (ps); + } + else + proxy_session_free (ps); + } } else { @@ -239,6 +282,7 @@ proxy_accept_callback (session_t * s) ps = proxy_session_alloc (); ps->vpp_server_handle = session_handle (s); ps->vpp_active_open_handle = SESSION_INVALID_HANDLE; + ps->po_thread_index = s->thread_index; s->opaque = ps->ps_index; diff --git a/src/plugins/hs_apps/proxy.h b/src/plugins/hs_apps/proxy.h index 4b4c7c0ca8f..6e770248cac 100644 --- a/src/plugins/hs_apps/proxy.h +++ b/src/plugins/hs_apps/proxy.h @@ -38,6 +38,7 @@ typedef struct volatile int ao_disconnected; u32 ps_index; + u32 po_thread_index; } proxy_session_t; typedef struct |