aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2020-04-30 15:05:24 +0000
committerDave Barach <openvpp@barachs.net>2020-04-30 20:50:14 +0000
commitbf39597d41da6d00e4d1a9954e42d16069069243 (patch)
tree17720444b6f830f21a194022d9ffa52e145e320e /src/vnet
parent240dcb24a00004017ec2d1b23b93d9ae8d3c9f65 (diff)
session: cleanup listener segment manager on wrk free
Type: fix Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: I1585af9e4f4273f055aed824b133ddc8eddd1df7
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/session/application_worker.c25
-rw-r--r--src/vnet/session/segment_manager.c2
-rw-r--r--src/vnet/session/segment_manager.h1
3 files changed, 18 insertions, 10 deletions
diff --git a/src/vnet/session/application_worker.c b/src/vnet/session/application_worker.c
index 8eebaf003e6..8e3ba35013a 100644
--- a/src/vnet/session/application_worker.c
+++ b/src/vnet/session/application_worker.c
@@ -56,7 +56,7 @@ app_worker_free (app_worker_t * app_wrk)
{
application_t *app = application_get (app_wrk->app_index);
vnet_unlisten_args_t _a, *a = &_a;
- u64 handle, *handles = 0;
+ u64 handle, *handles = 0, *sm_indices = 0;
segment_manager_t *sm;
session_t *ls;
u32 sm_index;
@@ -70,22 +70,29 @@ app_worker_free (app_worker_t * app_wrk)
hash_foreach (handle, sm_index, app_wrk->listeners_table, ({
ls = listen_session_get_from_handle (handle);
vec_add1 (handles, app_listen_session_handle (ls));
+ vec_add1 (sm_indices, sm_index);
sm = segment_manager_get (sm_index);
- sm->app_wrk_index = SEGMENT_MANAGER_INVALID_APP_INDEX;
}));
/* *INDENT-ON* */
- hash_free (app_wrk->listeners_table);
-
for (i = 0; i < vec_len (handles); i++)
{
+ /* Cleanup listener */
a->app_index = app->app_index;
a->wrk_map_index = app_wrk->wrk_map_index;
a->handle = handles[i];
- /* seg manager is removed when unbind completes */
(void) vnet_unlisten (a);
+
+ sm = segment_manager_get_if_valid (sm_indices[i]);
+ if (sm && !segment_manager_app_detached (sm))
+ {
+ sm->first_is_protected = 0;
+ segment_manager_init_free (sm);
+ }
}
vec_reset_length (handles);
+ vec_free (sm_indices);
+ hash_free (app_wrk->listeners_table);
/*
* Connects segment manager cleanup
@@ -124,11 +131,11 @@ app_worker_free (app_worker_t * app_wrk)
vec_free (app_wrk->half_open_table);
vec_free (handles);
- /* If first segment manager is used by a listener */
- if (app_wrk->first_segment_manager != APP_INVALID_SEGMENT_MANAGER_INDEX
- && app_wrk->first_segment_manager != app_wrk->connects_seg_manager)
+ /* If first segment manager is used by a listener that recently
+ * stopped listening, mark it as detached */
+ if (app_wrk->first_segment_manager != app_wrk->connects_seg_manager
+ && (sm = segment_manager_get_if_valid (app_wrk->first_segment_manager)))
{
- sm = segment_manager_get (app_wrk->first_segment_manager);
sm->first_is_protected = 0;
sm->app_wrk_index = SEGMENT_MANAGER_INVALID_APP_INDEX;
/* .. and has no fifos, e.g. it might be used for redirected sessions,
diff --git a/src/vnet/session/segment_manager.c b/src/vnet/session/segment_manager.c
index 3e0b8962c07..33ce6e58398 100644
--- a/src/vnet/session/segment_manager.c
+++ b/src/vnet/session/segment_manager.c
@@ -64,7 +64,7 @@ segment_manager_props_init (segment_manager_props_t * props)
return props;
}
-static u8
+u8
segment_manager_app_detached (segment_manager_t * sm)
{
return (sm->app_wrk_index == SEGMENT_MANAGER_INVALID_APP_INDEX);
diff --git a/src/vnet/session/segment_manager.h b/src/vnet/session/segment_manager.h
index 13b1fffa1e2..fbd9afa9858 100644
--- a/src/vnet/session/segment_manager.h
+++ b/src/vnet/session/segment_manager.h
@@ -140,6 +140,7 @@ void segment_manager_dealloc_queue (segment_manager_t * sm, svm_queue_t * q);
svm_msg_q_t *segment_manager_event_queue (segment_manager_t * sm);
u32 segment_manager_evt_q_expected_size (u32 q_size);
+u8 segment_manager_app_detached (segment_manager_t * sm);
void segment_manager_app_detach (segment_manager_t * sm);
/**