memset (app, 0, sizeof (*app));
app->index = application_get_index (app);
app->connects_seg_manager = ~0;
+ app->first_segment_manager = ~0;
+ if (CLIB_DEBUG > 1)
+ clib_warning ("[%d] New app (%d)", getpid (), app->index);
return app;
}
* The app event queue allocated in first segment is cleared with
* the segment manager. No need to explicitly free it.
*/
+ if (CLIB_DEBUG > 1)
+ clib_warning ("[%d] Delete app (%d)", getpid (), app->index);
/*
* Cleanup segment managers
*/
- if (app->connects_seg_manager != (u32) ~ 0)
+ if ((app->connects_seg_manager != (u32) ~ 0) &&
+ (app->connects_seg_manager != app->first_segment_manager))
{
sm = segment_manager_get (app->connects_seg_manager);
segment_manager_del (sm);
/* Actual listener cleanup */
for (i = 0; i < vec_len (handles); i++)
{
- a->app_index = app->api_client_index;
+ a->app_index = app->index;
a->handle = handles[i];
/* seg manager is removed when unbind completes */
vnet_unbind (a);
}
+ if (app->first_segment_manager != ~0)
+ {
+ sm = segment_manager_get (app->first_segment_manager);
+ segment_manager_first_segment_maybe_del (sm);
+ }
+
application_table_del (app);
pool_put (app_pool, app);
}
props->preallocated_fifo_pairs = options[APP_OPTIONS_PREALLOC_FIFO_PAIRS];
props->use_private_segment = options[APP_OPTIONS_FLAGS]
& APP_OPTIONS_FLAGS_BUILTIN_APP;
+ props->private_segment_count = options[APP_OPTIONS_PRIVATE_SEGMENT_COUNT];
+ props->private_segment_size = options[APP_OPTIONS_PRIVATE_SEGMENT_SIZE];
first_seg_size = options[SESSION_OPTIONS_SEGMENT_SIZE];
if ((rv = segment_manager_init (sm, props, first_seg_size)))
{
segment_manager_t *sm = 0;
- if (app->first_segment_manager != (u32) ~ 0)
+ if (app->first_segment_manager != (u32) ~ 0
+ && app->first_segment_manager_in_use == 0)
{
sm = segment_manager_get (app->first_segment_manager);
- app->first_segment_manager = ~0;
+ app->first_segment_manager_in_use = 1;
return sm;
}
sm = segment_manager_new ();
- if (segment_manager_init (sm, &app->sm_properties, 0))
- return 0;
+ sm->properties = &app->sm_properties;
+
return sm;
}
sm = segment_manager_get (*indexp);
segment_manager_del (sm);
+ if (srv->first_segment_manager == *indexp)
+ {
+ srv->first_segment_manager_in_use = 0;
+ srv->first_segment_manager = ~0;
+ }
hash_unset (srv->listeners_table, handle);
listen_session_del (listener);
return rv;
/* Store api_context for when the reply comes. Not the nicest thing
- * but better allocating a separate half-open pool. */
+ * but better than allocating a separate half-open pool. */
tc->s_index = api_context;
return 0;
return app_name;
}
+int
+application_is_proxy (application_t * app)
+{
+ return !(app->flags & APP_OPTIONS_FLAGS_IS_PROXY);
+}
+
u8 *
format_application_listener (u8 * s, va_list * args)
{