aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/session
diff options
context:
space:
mode:
authorDave Wallace <dwallacelf@gmail.com>2017-07-05 14:30:46 -0400
committerFlorin Coras <florin.coras@gmail.com>2017-07-06 23:28:27 +0000
commit7b749fe890a4acb23431148859c25643a3597d2a (patch)
treeccf6f19d5c2af8cebd23adfbdfca829a0fd05e14 /src/vnet/session
parent4729b1ec83855268adcea3e00a3462c06a631075 (diff)
Unlink /dev/shm files on application detach.
Change-Id: Ieb5522cd5cb27bcbce808d4cd6df5248716da43c Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
Diffstat (limited to 'src/vnet/session')
-rw-r--r--src/vnet/session/application.c13
-rw-r--r--src/vnet/session/application_interface.c2
-rw-r--r--src/vnet/session/segment_manager.c25
-rw-r--r--src/vnet/session/segment_manager.h1
4 files changed, 36 insertions, 5 deletions
diff --git a/src/vnet/session/application.c b/src/vnet/session/application.c
index 4bdb10271ab..3cc56f3794f 100644
--- a/src/vnet/session/application.c
+++ b/src/vnet/session/application.c
@@ -81,6 +81,9 @@ application_new ()
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;
}
@@ -97,6 +100,8 @@ application_del (application_t * 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
@@ -123,6 +128,12 @@ application_del (application_t * app)
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);
}
@@ -214,7 +225,6 @@ application_alloc_segment_manager (application_t * app)
if (app->first_segment_manager != (u32) ~ 0)
{
sm = segment_manager_get (app->first_segment_manager);
- app->first_segment_manager = ~0;
return sm;
}
@@ -288,6 +298,7 @@ application_stop_listen (application_t * srv, u64 handle)
sm = segment_manager_get (*indexp);
segment_manager_del (sm);
+ srv->first_segment_manager = ~0;
hash_unset (srv->listeners_table, handle);
listen_session_del (listener);
diff --git a/src/vnet/session/application_interface.c b/src/vnet/session/application_interface.c
index f74b0cfe99c..338ae857dab 100644
--- a/src/vnet/session/application_interface.c
+++ b/src/vnet/session/application_interface.c
@@ -113,7 +113,7 @@ vnet_unbind_i (u32 app_index, u64 handle)
if (!app)
{
- clib_warning ("app not attached");
+ clib_warning ("app (%d) not attached", app_index);
return VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
}
diff --git a/src/vnet/session/segment_manager.c b/src/vnet/session/segment_manager.c
index bf571963b0e..dcef62615d2 100644
--- a/src/vnet/session/segment_manager.c
+++ b/src/vnet/session/segment_manager.c
@@ -67,7 +67,6 @@ session_manager_add_segment_i (segment_manager_t * sm, u32 segment_size,
{
clib_warning ("svm_fifo_segment_create ('%s', %d) failed",
ca->segment_name, ca->segment_size);
- vec_free (segment_name);
return VNET_API_ERROR_SVM_SEGMENT_CREATE_FAIL;
}
@@ -167,7 +166,24 @@ segment_manager_init (segment_manager_t * sm,
return 0;
}
-/**
+void
+segment_manager_first_segment_maybe_del (segment_manager_t * sm)
+{
+ svm_fifo_segment_private_t *fifo_segment;
+
+ /* If the first semgment has no fifos, then delete the 1st segment
+ */
+ fifo_segment = svm_fifo_get_segment (sm->segment_indices[0]);
+ if (!svm_fifo_segment_has_fifos (fifo_segment))
+ {
+ clib_spinlock_lock (&sm->lockp);
+ svm_fifo_segment_delete (fifo_segment);
+ vec_del1 (sm->segment_indices, 0);
+ clib_spinlock_unlock (&sm->lockp);
+ }
+}
+
+ /**
* Removes segment manager.
*
* Since the fifos allocated in the segment keep backpointers to the sessions
@@ -178,11 +194,12 @@ void
segment_manager_del (segment_manager_t * sm)
{
int j;
+ svm_fifo_segment_private_t *fifo_segment;
+ ASSERT (vec_len (sm->segment_indices));
/* 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 *fifo;
/* Vector of fifos allocated in the segment */
@@ -216,6 +233,8 @@ segment_manager_del (segment_manager_t * sm)
*/
}
+ segment_manager_first_segment_maybe_del (sm);
+
clib_spinlock_free (&sm->lockp);
pool_put (segment_managers, sm);
}
diff --git a/src/vnet/session/segment_manager.h b/src/vnet/session/segment_manager.h
index d4b73208257..df38d2b35f9 100644
--- a/src/vnet/session/segment_manager.h
+++ b/src/vnet/session/segment_manager.h
@@ -96,6 +96,7 @@ segment_manager_init (segment_manager_t * sm,
void segment_manager_get_segment_info (u32 index, u8 ** name, u32 * size);
int
session_manager_add_first_segment (segment_manager_t * sm, u32 segment_size);
+void segment_manager_first_segment_maybe_del (segment_manager_t * sm);
int session_manager_add_segment (segment_manager_t * sm);
void segment_manager_del (segment_manager_t * sm);
int