summaryrefslogtreecommitdiffstats
path: root/src/vcl/vcl_private.c
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2022-03-01 18:07:09 -0800
committerDave Barach <openvpp@barachs.net>2022-03-02 19:35:52 +0000
commitfe6d8a37062a28f28ee63c3e9177d18c10ed96e1 (patch)
tree460197f488672213a0553a67d8dc5d754425bc7c /src/vcl/vcl_private.c
parent6a2c6a0445b243e0dc7e0c37250527bfd90dd55d (diff)
vcl: fix segment detach post api disconnect
Type: fix Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: I0982f0f5c8186f9ed962db49a14f35aa19f6a276
Diffstat (limited to 'src/vcl/vcl_private.c')
-rw-r--r--src/vcl/vcl_private.c43
1 files changed, 35 insertions, 8 deletions
diff --git a/src/vcl/vcl_private.c b/src/vcl/vcl_private.c
index b6ef815b53d..95cc0bfc3f4 100644
--- a/src/vcl/vcl_private.c
+++ b/src/vcl/vcl_private.c
@@ -188,6 +188,8 @@ vcl_worker_detach_sessions (vcl_worker_t *wrk)
{
session_event_t *e;
vcl_session_t *s;
+ uword *seg_indices_map = 0;
+ u32 seg_index, val, *seg_indices = 0;
close (wrk->app_api_sock.fd);
pool_foreach (s, wrk->sessions)
@@ -197,9 +199,13 @@ vcl_worker_detach_sessions (vcl_worker_t *wrk)
s->session_state = VCL_STATE_LISTEN_NO_MQ;
continue;
}
- if (s->flags & VCL_SESSION_F_IS_VEP)
+ if ((s->flags & VCL_SESSION_F_IS_VEP) ||
+ s->session_state == VCL_STATE_LISTEN_NO_MQ ||
+ s->session_state == VCL_STATE_CLOSED)
continue;
+ hash_set (seg_indices_map, s->tx_fifo->segment_index, 1);
+
s->session_state = VCL_STATE_DETACHED;
vec_add2 (wrk->unhandled_evts_vector, e, 1);
e->event_type = SESSION_CTRL_EVT_DISCONNECTED;
@@ -207,7 +213,16 @@ vcl_worker_detach_sessions (vcl_worker_t *wrk)
e->postponed = 1;
}
- vcl_segment_detach_all ();
+ hash_foreach (seg_index, val, seg_indices_map,
+ ({ vec_add1 (seg_indices, seg_index); }));
+
+ vcl_segment_detach_segments (seg_indices);
+
+ /* Detach worker's mqs segment */
+ vcl_segment_detach (vcl_vpp_worker_segment_handle (wrk->wrk_index));
+
+ vec_free (seg_indices);
+ hash_free (seg_indices_map);
}
vcl_worker_t *
@@ -463,21 +478,33 @@ vcl_segment_detach (u64 segment_handle)
}
void
-vcl_segment_detach_all ()
+vcl_segment_detach_segments (u32 *seg_indices)
{
- u64 *segs = 0, *seg, key;
+ u64 *seg_handles = 0, *seg_handle, key;
+ u32 *seg_index;
u32 val;
clib_rwlock_reader_lock (&vcm->segment_table_lock);
- hash_foreach (key, val, vcm->segment_table, ({ vec_add1 (segs, key); }));
+ vec_foreach (seg_index, seg_indices)
+ {
+ /* clang-format off */
+ hash_foreach (key, val, vcm->segment_table, ({
+ if (val == *seg_index)
+ {
+ vec_add1 (seg_handles, key);
+ break;
+ }
+ }));
+ /* clang-format on */
+ }
clib_rwlock_reader_unlock (&vcm->segment_table_lock);
- vec_foreach (seg, segs)
- vcl_segment_detach (seg[0]);
+ vec_foreach (seg_handle, seg_handles)
+ vcl_segment_detach (seg_handle[0]);
- vec_free (segs);
+ vec_free (seg_handles);
}
int