aboutsummaryrefslogtreecommitdiffstats
path: root/src/vlibmemory/memory_shared.c
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2018-01-29 05:11:24 -0800
committerDamjan Marion <dmarion.lists@gmail.com>2018-02-02 09:11:33 +0000
commitd6c30d9cae3ec8946c75d9ed87d40c053e2c083a (patch)
tree3addc31e5f2499a04cf3ffb5873e3f4c3e5a54e2 /src/vlibmemory/memory_shared.c
parentf2d0611e1bca0cca0776dc833fd42ae7b358d8e4 (diff)
vlmemory/svm: fix client detach from svm region
Clients cannot know at svm region detach time if the shm backing files have been recreated (e.g., if vpp restarts) and therefore should not try to unlink them. Otherwise, terminating clients attached to previous instantiations of a re-allocated region end up making the new instance un-mappable by removing its backing file. Change-Id: Idcd0cab776e63fd75b821bc9f0fac58217b9ccbe Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vlibmemory/memory_shared.c')
-rw-r--r--src/vlibmemory/memory_shared.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/vlibmemory/memory_shared.c b/src/vlibmemory/memory_shared.c
index 488a302bbba..c8c071f9a45 100644
--- a/src/vlibmemory/memory_shared.c
+++ b/src/vlibmemory/memory_shared.c
@@ -663,8 +663,8 @@ vl_register_mapped_shmem_region (svm_region_t * rp)
vec_add1 (am->mapped_shmem_regions, rp);
}
-void
-vl_unmap_shmem (void)
+static void
+vl_unmap_shmem_internal (u8 is_client)
{
svm_region_t *rp;
int i;
@@ -676,13 +676,14 @@ vl_unmap_shmem (void)
for (i = 0; i < vec_len (am->mapped_shmem_regions); i++)
{
rp = am->mapped_shmem_regions[i];
- svm_region_unmap (rp);
+ is_client ? svm_region_unmap_client (rp) : svm_region_unmap (rp);
}
vec_free (am->mapped_shmem_regions);
am->shmem_hdr = 0;
- svm_region_exit ();
+ is_client ? svm_region_exit_client () : svm_region_exit ();
+
/* $$$ more careful cleanup, valgrind run... */
vec_free (am->msg_handlers);
vec_free (am->msg_endian_handlers);
@@ -690,6 +691,18 @@ vl_unmap_shmem (void)
}
void
+vl_unmap_shmem (void)
+{
+ vl_unmap_shmem_internal (0);
+}
+
+void
+vl_unmap_shmem_client (void)
+{
+ vl_unmap_shmem_internal (1);
+}
+
+void
vl_msg_api_send_shmem (svm_queue_t * q, u8 * elem)
{
api_main_t *am = &api_main;