aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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);
/**