aboutsummaryrefslogtreecommitdiffstats
path: root/src/vlibmemory/memory_api.c
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2018-12-04 16:34:05 -0800
committerDave Barach <openvpp@barachs.net>2018-12-05 15:38:51 +0000
commiteaec2a6d9ab8b983aaee536be1a95846c07a9d7f (patch)
treefdea9758127769ab978e9fc5c737282a85ba821a /src/vlibmemory/memory_api.c
parent955bfbbb6968bdc99171bdebcda6dbe605af2004 (diff)
bapi: add options to have vpp cleanup client registration
A client can send a memclnt delete message and ask vpp to cleanup the shared memory queue. Obviously, in this case no delete reply is sent back to the client. Change-Id: I9c8375093f8607680ad498a6bed0690ba02a7c3b Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vlibmemory/memory_api.c')
-rw-r--r--src/vlibmemory/memory_api.c38
1 files changed, 22 insertions, 16 deletions
diff --git a/src/vlibmemory/memory_api.c b/src/vlibmemory/memory_api.c
index 544e59ddb69..cb15f0c762d 100644
--- a/src/vlibmemory/memory_api.c
+++ b/src/vlibmemory/memory_api.c
@@ -296,23 +296,27 @@ vl_api_memclnt_delete_t_handler (vl_api_memclnt_delete_t * mp)
svm = am->vlib_rp;
int private_registration = 0;
- /*
- * Note: the API message handling path will set am->vlib_rp
- * as appropriate for pairwise / private memory segments
- */
- rp = vl_msg_api_alloc (sizeof (*rp));
- rp->_vl_msg_id = ntohs (VL_API_MEMCLNT_DELETE_REPLY);
- rp->handle = mp->handle;
- rp->response = 1;
-
- vl_msg_api_send_shmem (regp->vl_input_queue, (u8 *) & rp);
-
- if (client_index != regp->vl_api_registration_pool_index)
+ /* Send reply unless client asked us to do the cleanup */
+ if (!mp->do_cleanup)
{
- clib_warning ("mismatch client_index %d pool_index %d",
- client_index, regp->vl_api_registration_pool_index);
- vl_msg_api_free (rp);
- return;
+ /*
+ * Note: the API message handling path will set am->vlib_rp
+ * as appropriate for pairwise / private memory segments
+ */
+ rp = vl_msg_api_alloc (sizeof (*rp));
+ rp->_vl_msg_id = ntohs (VL_API_MEMCLNT_DELETE_REPLY);
+ rp->handle = mp->handle;
+ rp->response = 1;
+
+ vl_msg_api_send_shmem (regp->vl_input_queue, (u8 *) & rp);
+ if (client_index != regp->vl_api_registration_pool_index)
+ {
+ clib_warning ("mismatch client_index %d pool_index %d",
+ client_index,
+ regp->vl_api_registration_pool_index);
+ vl_msg_api_free (rp);
+ return;
+ }
}
/* For horizontal scaling, add a hash table... */
@@ -352,6 +356,8 @@ vl_api_memclnt_delete_t_handler (vl_api_memclnt_delete_t * mp)
regp->vl_api_registration_pool_index);
pthread_mutex_lock (&svm->mutex);
oldheap = svm_push_data_heap (svm);
+ if (mp->do_cleanup)
+ svm_queue_free (regp->vl_input_queue);
vec_free (regp->name);
/* Poison the old registration */
clib_memset (regp, 0xF1, sizeof (*regp));