summaryrefslogtreecommitdiffstats
path: root/src/vnet/session/application.c
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2017-04-19 13:00:05 -0700
committerDave Barach <openvpp@barachs.net>2017-04-24 12:02:14 +0000
commita5464817522c7a7dc760af4612f1d6a68ed0afc8 (patch)
treec173b6d4e0fac69394d3c1b61a842dc582b2a218 /src/vnet/session/application.c
parentbc66a9122f73b97ca1ae60f1df47b39c141be3ae (diff)
Session layer improvements
Among others: - Moved app event queue to shared memory segment - Use private memory segment for builtin apps - Remove pid from svm fifo - Protect session fifo (de)allocation - Use fifo event for session disconnects - Have session queue node poll in all wk threads Change-Id: I89dbf7fdfebef12f5ef2b34ba3ef3c2c07f49ff2 Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vnet/session/application.c')
-rw-r--r--src/vnet/session/application.c48
1 files changed, 16 insertions, 32 deletions
diff --git a/src/vnet/session/application.c b/src/vnet/session/application.c
index 5a45537b798..ccf9837f4cc 100644
--- a/src/vnet/session/application.c
+++ b/src/vnet/session/application.c
@@ -87,8 +87,6 @@ application_new ()
void
application_del (application_t * app)
{
- api_main_t *am = &api_main;
- void *oldheap;
segment_manager_t *sm;
u64 handle;
u32 index, *handles = 0;
@@ -96,6 +94,11 @@ application_del (application_t * app)
vnet_unbind_args_t _a, *a = &_a;
/*
+ * The app event queue allocated in first segment is cleared with
+ * the segment manager. No need to explicitly free it.
+ */
+
+ /*
* Cleanup segment managers
*/
if (app->connects_seg_manager != (u32) ~ 0)
@@ -120,14 +123,6 @@ application_del (application_t * app)
vnet_unbind (a);
}
- /*
- * Free the event fifo in the /vpe-api shared-memory segment
- */
- oldheap = svm_push_data_heap (am->vlib_rp);
- if (app->event_queue)
- unix_shared_memory_queue_free (app->event_queue);
- svm_pop_heap (oldheap);
-
application_table_del (app);
pool_put (app_pool, app);
}
@@ -149,30 +144,14 @@ int
application_init (application_t * app, u32 api_client_index, u64 * options,
session_cb_vft_t * cb_fns)
{
- api_main_t *am = &api_main;
segment_manager_t *sm;
segment_manager_properties_t *props;
- void *oldheap;
- u32 app_evt_queue_size;
+ u32 app_evt_queue_size, first_seg_size;
int rv;
app_evt_queue_size = options[APP_EVT_QUEUE_SIZE] > 0 ?
options[APP_EVT_QUEUE_SIZE] : default_app_evt_queue_size;
- /* Allocate event fifo in the /vpe-api shared-memory segment */
- oldheap = svm_push_data_heap (am->vlib_rp);
-
- /* Allocate server event queue */
- app->event_queue =
- unix_shared_memory_queue_init (app_evt_queue_size,
- sizeof (session_fifo_event_t),
- 0 /* consumer pid */ ,
- 0
- /* (do not) signal when queue non-empty */
- );
-
- svm_pop_heap (oldheap);
-
/* Setup segment manager */
sm = segment_manager_new ();
sm->app_index = app->index;
@@ -181,16 +160,21 @@ application_init (application_t * app, u32 api_client_index, u64 * options,
props->rx_fifo_size = options[SESSION_OPTIONS_RX_FIFO_SIZE];
props->tx_fifo_size = options[SESSION_OPTIONS_TX_FIFO_SIZE];
props->add_segment = props->add_segment_size != 0;
+ props->use_private_segment = options[APP_OPTIONS_FLAGS]
+ & APP_OPTIONS_FLAGS_BUILTIN_APP;
- if ((rv = segment_manager_init (sm, props,
- options[SESSION_OPTIONS_SEGMENT_SIZE])))
+ first_seg_size = options[SESSION_OPTIONS_SEGMENT_SIZE];
+ if ((rv = segment_manager_init (sm, props, first_seg_size)))
return rv;
app->first_segment_manager = segment_manager_index (sm);
app->api_client_index = api_client_index;
- app->flags = options[SESSION_OPTIONS_FLAGS];
+ app->flags = options[APP_OPTIONS_FLAGS];
app->cb_fns = *cb_fns;
+ /* Allocate app event queue in the first shared-memory segment */
+ app->event_queue = segment_manager_alloc_queue (sm, app_evt_queue_size);
+
/* Check that the obvious things are properly set up */
application_verify_cb_fns (cb_fns);
@@ -451,8 +435,8 @@ application_format_connects (application_t * app, int verbose)
continue;
fifo = fifos[i];
- session_index = fifo->server_session_index;
- thread_index = fifo->server_thread_index;
+ session_index = fifo->master_session_index;
+ thread_index = fifo->master_thread_index;
session = stream_session_get (session_index, thread_index);
str = format (0, "%U", format_stream_session, session, verbose);