aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/session/segment_manager.c
diff options
context:
space:
mode:
authorliuyacan <liuyacan@corp.netease.com>2021-04-28 11:34:03 +0000
committerFlorin Coras <florin.coras@gmail.com>2021-04-29 17:52:53 +0000
commit87d48ad8f6e8008bfd7ffaf56c91cb0c8b362330 (patch)
tree14f8706c4fecd36fd82115e0264db52cf024ad3d /src/vnet/session/segment_manager.c
parent5c481ff732caef6cbd4e3c095e802f095a920d82 (diff)
session: cleanup CREATED sessions when listener goes down
We should cleanup sessions in CREATED state when listener goes down, otherwise they may use unpredictable sessions as listeners later. Type: fix Signed-off-by: liuyacan <liuyacan@corp.netease.com> Change-Id: Ifbd0a0fb46275bd9d89e5aee19a70c1d01d15764
Diffstat (limited to 'src/vnet/session/segment_manager.c')
-rw-r--r--src/vnet/session/segment_manager.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/vnet/session/segment_manager.c b/src/vnet/session/segment_manager.c
index 73b2f7177bd..103f89ecfa8 100644
--- a/src/vnet/session/segment_manager.c
+++ b/src/vnet/session/segment_manager.c
@@ -626,6 +626,59 @@ segment_manager_del_sessions (segment_manager_t * sm)
vec_free (handles);
}
+/**
+ * Initiate disconnects for sessions in specified state 'owned' by a segment
+ * manager
+ */
+void
+segment_manager_del_sessions_filter (segment_manager_t *sm,
+ session_state_t *states)
+{
+ session_handle_t *handles = 0, *handle;
+ fifo_segment_t *fs;
+ session_t *session;
+ int slice_index;
+ svm_fifo_t *f;
+
+ ASSERT (pool_elts (sm->segments) != 0);
+
+ /* Across all fifo segments used by the server */
+ segment_manager_foreach_segment_w_lock (
+ fs, sm, ({
+ for (slice_index = 0; slice_index < fs->n_slices; slice_index++)
+ {
+ f = fifo_segment_get_slice_fifo_list (fs, slice_index);
+ while (f)
+ {
+ session = session_get_if_valid (f->shr->master_session_index,
+ f->master_thread_index);
+ if (session)
+ {
+ session_state_t *state;
+ vec_foreach (state, states)
+ {
+ if (session->session_state == *state)
+ {
+ vec_add1 (handles, session_handle (session));
+ break;
+ }
+ }
+ }
+ f = f->next;
+ }
+ }
+ }));
+
+ vec_foreach (handle, handles)
+ {
+ session = session_get_from_handle (*handle);
+ session_close (session);
+ /* Avoid propagating notifications back to the app */
+ session->app_wrk_index = APP_INVALID_INDEX;
+ }
+ vec_free (handles);
+}
+
int
segment_manager_try_alloc_fifos (fifo_segment_t * fifo_segment,
u32 thread_index,