- /* Allocate event fifo in the /vpe-api shared-memory segment */
- oldheap = svm_push_data_heap (am->vlib_rp);
-
- smm->vpp_event_queues[thread_index] =
- unix_shared_memory_queue_init (2048 /* nels $$$$ config */ ,
- sizeof (session_fifo_event_t),
- 0 /* consumer pid */ ,
- 0
- /* (do not) send signal when queue non-empty */
- );
-
- svm_pop_heap (oldheap);
- }
-}
-
-void
-session_manager_get_segment_info (u32 index, u8 ** name, u32 * size)
-{
- svm_fifo_segment_private_t *s;
- s = svm_fifo_get_segment (index);
- *name = s->h->segment_name;
- *size = s->ssvm.ssvm_size;
-}
-
-always_inline int
-session_manager_add_segment_i (session_manager_main_t * smm,
- session_manager_t * sm,
- u32 segment_size, u8 * segment_name)
-{
- svm_fifo_segment_create_args_t _ca, *ca = &_ca;
- int rv;
-
- memset (ca, 0, sizeof (*ca));
-
- ca->segment_name = (char *) segment_name;
- ca->segment_size = segment_size;
-
- rv = svm_fifo_segment_create (ca);
- if (rv)
- {
- clib_warning ("svm_fifo_segment_create ('%s', %d) failed",
- ca->segment_name, ca->segment_size);
- vec_free (segment_name);
- return -1;
- }
-
- vec_add1 (sm->segment_indices, ca->new_segment_index);
-
- return 0;
-}
-
-static int
-session_manager_add_segment (session_manager_main_t * smm,
- session_manager_t * sm)
-{
- u8 *segment_name;
- svm_fifo_segment_create_args_t _ca, *ca = &_ca;
- u32 add_segment_size;
- u32 default_segment_size = 128 << 10;
-
- memset (ca, 0, sizeof (*ca));
- segment_name = format (0, "%d-%d%c", getpid (),
- smm->unique_segment_name_counter++, 0);
- add_segment_size =
- sm->add_segment_size ? sm->add_segment_size : default_segment_size;
-
- return session_manager_add_segment_i (smm, sm, add_segment_size,
- segment_name);
-}
-
-int
-session_manager_add_first_segment (session_manager_main_t * smm,
- session_manager_t * sm, u32 segment_size,
- u8 ** segment_name)
-{
- svm_fifo_segment_create_args_t _ca, *ca = &_ca;
- memset (ca, 0, sizeof (*ca));
- *segment_name = format (0, "%d-%d%c", getpid (),
- smm->unique_segment_name_counter++, 0);
- return session_manager_add_segment_i (smm, sm, segment_size, *segment_name);
-}
-
-void
-session_manager_del (session_manager_main_t * smm, session_manager_t * sm)
-{
- u32 *deleted_sessions = 0;
- u32 *deleted_thread_indices = 0;
- int i, j;
-
- /* Across all fifo segments used by the server */
- for (j = 0; j < vec_len (sm->segment_indices); j++)
- {
- svm_fifo_segment_private_t *fifo_segment;
- svm_fifo_t **fifos;
- /* Vector of fifos allocated in the segment */
- fifo_segment = svm_fifo_get_segment (sm->segment_indices[j]);
- fifos = (svm_fifo_t **) fifo_segment->h->fifos;
-
- /*
- * Remove any residual sessions from the session lookup table
- * Don't bother deleting the individual fifos, we're going to
- * throw away the fifo segment in a minute.
- */
- for (i = 0; i < vec_len (fifos); i++)