diff options
-rw-r--r-- | src/vcl/vcl_private.c | 43 | ||||
-rw-r--r-- | src/vcl/vcl_private.h | 2 |
2 files changed, 36 insertions, 9 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 diff --git a/src/vcl/vcl_private.h b/src/vcl/vcl_private.h index e4f1c149b2d..9c905333440 100644 --- a/src/vcl/vcl_private.h +++ b/src/vcl/vcl_private.h @@ -716,7 +716,7 @@ int vcl_send_worker_rpc (u32 dst_wrk_index, void *data, u32 data_len); int vcl_segment_attach (u64 segment_handle, char *name, ssvm_segment_type_t type, int fd); void vcl_segment_detach (u64 segment_handle); -void vcl_segment_detach_all (); +void vcl_segment_detach_segments (u32 *seg_indices); void vcl_send_session_unlisten (vcl_worker_t * wrk, vcl_session_t * s); int vcl_segment_attach_session (uword segment_handle, uword rxf_offset, |