summaryrefslogtreecommitdiffstats
path: root/src/vnet/session/application_worker.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/session/application_worker.c')
-rw-r--r--src/vnet/session/application_worker.c74
1 files changed, 13 insertions, 61 deletions
diff --git a/src/vnet/session/application_worker.c b/src/vnet/session/application_worker.c
index 8c3be22d4dc..7e03171b115 100644
--- a/src/vnet/session/application_worker.c
+++ b/src/vnet/session/application_worker.c
@@ -32,7 +32,6 @@ app_worker_alloc (application_t * app)
app_wrk->app_index = app->app_index;
app_wrk->wrk_map_index = ~0;
app_wrk->connects_seg_manager = APP_INVALID_SEGMENT_MANAGER_INDEX;
- app_wrk->first_segment_manager = APP_INVALID_SEGMENT_MANAGER_INDEX;
clib_spinlock_init (&app_wrk->detached_seg_managers_lock);
APP_DBG ("New app %v worker %u", app->name, app_wrk->wrk_index);
return app_wrk;
@@ -143,17 +142,6 @@ app_worker_free (app_worker_t * app_wrk)
vec_free (app_wrk->detached_seg_managers);
clib_spinlock_free (&app_wrk->detached_seg_managers_lock);
- /* 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))
- && !segment_manager_app_detached (sm))
- {
- sm->first_is_protected = 0;
- sm->app_wrk_index = SEGMENT_MANAGER_INVALID_APP_INDEX;
- segment_manager_init_free (sm);
- }
-
if (CLIB_DEBUG)
clib_memset (app_wrk, 0xfe, sizeof (*app_wrk));
pool_put (app_workers, app_wrk);
@@ -172,19 +160,9 @@ app_worker_get_app (u32 wrk_index)
static segment_manager_t *
app_worker_alloc_segment_manager (app_worker_t * app_wrk)
{
- segment_manager_t *sm = 0;
+ segment_manager_t *sm;
- /* If the first segment manager is not in use, don't allocate a new one */
- if (app_wrk->first_segment_manager != APP_INVALID_SEGMENT_MANAGER_INDEX
- && app_wrk->first_segment_manager_in_use == 0)
- {
- sm = segment_manager_get (app_wrk->first_segment_manager);
- app_wrk->first_segment_manager_in_use = 1;
- }
- else
- {
- sm = segment_manager_alloc ();
- }
+ sm = segment_manager_alloc ();
sm->app_wrk_index = app_wrk->wrk_index;
segment_manager_init (sm);
return sm;
@@ -309,20 +287,21 @@ app_worker_stop_listen_session (app_worker_t * app_wrk, session_t * ls)
/* Try to cleanup segment manager */
sm = segment_manager_get (*sm_indexp);
- if (sm && segment_manager_has_fifos (sm))
- {
- /* Delete sessions in CREATED state */
- vec_add1 (states, SESSION_STATE_CREATED);
- segment_manager_del_sessions_filter (sm, states);
- vec_free (states);
- }
- if (sm && app_wrk->first_segment_manager != *sm_indexp)
+ if (sm)
{
segment_manager_app_detach (sm);
if (!segment_manager_has_fifos (sm))
- segment_manager_free (sm);
+ {
+ /* Empty segment manager, cleanup it up */
+ segment_manager_free (sm);
+ }
else
{
+ /* Delete sessions in CREATED state */
+ vec_add1 (states, SESSION_STATE_CREATED);
+ segment_manager_del_sessions_filter (sm, states);
+ vec_free (states);
+
/* Track segment manager in case app detaches and all the
* outstanding sessions need to be closed */
app_worker_add_detached_sm (app_wrk, *sm_indexp);
@@ -534,7 +513,7 @@ app_worker_own_session (app_worker_t * app_wrk, session_t * s)
s->rx_fifo = 0;
s->tx_fifo = 0;
- sm = app_worker_get_or_alloc_connect_segment_manager (app_wrk);
+ sm = app_worker_get_connect_segment_manager (app_wrk);
if (app_worker_alloc_session_fifos (sm, s))
return -1;
@@ -555,10 +534,6 @@ app_worker_connect_session (app_worker_t * app_wrk, session_endpoint_t * sep,
{
int rv;
- /* Make sure we have a segment manager for connects */
- if (app_worker_alloc_connects_segment_manager (app_wrk))
- return SESSION_E_ALLOC;
-
if ((rv = session_open (app_wrk->wrk_index, sep, api_context)))
return rv;
@@ -574,21 +549,6 @@ app_worker_session_fifo_tuning (app_worker_t * app_wrk, session_t * s,
return app->cb_fns.fifo_tuning_callback (s, f, act, len);
}
-int
-app_worker_alloc_connects_segment_manager (app_worker_t * app_wrk)
-{
- segment_manager_t *sm;
-
- if (app_wrk->connects_seg_manager == APP_INVALID_SEGMENT_MANAGER_INDEX)
- {
- sm = app_worker_alloc_segment_manager (app_wrk);
- if (sm == 0)
- return -1;
- app_wrk->connects_seg_manager = segment_manager_index (sm);
- }
- return 0;
-}
-
segment_manager_t *
app_worker_get_connect_segment_manager (app_worker_t * app)
{
@@ -597,14 +557,6 @@ app_worker_get_connect_segment_manager (app_worker_t * app)
}
segment_manager_t *
-app_worker_get_or_alloc_connect_segment_manager (app_worker_t * app_wrk)
-{
- if (app_wrk->connects_seg_manager == (u32) ~ 0)
- app_worker_alloc_connects_segment_manager (app_wrk);
- return segment_manager_get (app_wrk->connects_seg_manager);
-}
-
-segment_manager_t *
app_worker_get_listen_segment_manager (app_worker_t * app,
session_t * listener)
{