diff mbox

[PATCHv3,08/10] linux-generic: shm: add term_global

Message ID 1424723769-8762-9-git-send-email-robking@cisco.com
State New
Headers show

Commit Message

Robbie King Feb. 23, 2015, 8:36 p.m. UTC
From: Yan Sonming <yan.songming@linaro.org>

Signed-off-by: Yan Songming <yan.songming@linaro.org>
Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
Signed-off-by: Robbie King <robking@cisco.com>
---
 platform/linux-generic/include/odp_internal.h | 1 +
 platform/linux-generic/odp_init.c             | 5 +++++
 platform/linux-generic/odp_shared_memory.c    | 8 ++++++++
 3 files changed, 14 insertions(+)

Comments

Maxim Uvarov Feb. 24, 2015, 1:07 p.m. UTC | #1
On 02/23/2015 11:36 PM, Robbie King wrote:
> +int odp_shm_term_global(void)
> +{
> +	int ret = 0;
> +
no need to set it to 0.

+	ret = munmap(odp_shm_tbl, sizeof(odp_shm_table_t));

Please add some debug message:
if (ret)
     ODP_ERR("unable to munmap\n.");

2 errors can be here: 1) area already unmapped 2)odp_shm_tbl memory 
corruption.


Maxim.
> +	return ret;
> +}
> +
diff mbox

Patch

diff --git a/platform/linux-generic/include/odp_internal.h b/platform/linux-generic/include/odp_internal.h
index dad844f..4b9630c 100644
--- a/platform/linux-generic/include/odp_internal.h
+++ b/platform/linux-generic/include/odp_internal.h
@@ -37,6 +37,7 @@  int odp_thread_term_local(void);
 int odp_thread_term_global(void);
 
 int odp_shm_init_global(void);
+int odp_shm_term_global(void);
 int odp_shm_init_local(void);
 
 int odp_pool_init_global(void);
diff --git a/platform/linux-generic/odp_init.c b/platform/linux-generic/odp_init.c
index cdc4565..7426a97 100644
--- a/platform/linux-generic/odp_init.c
+++ b/platform/linux-generic/odp_init.c
@@ -113,6 +113,11 @@  int odp_term_global(void)
 		rc = -1;
 	}
 
+	if (odp_shm_term_global()) {
+		ODP_ERR("ODP shm term failed.\n");
+		rc = -1;
+	}
+
 	return rc;
 }
 
diff --git a/platform/linux-generic/odp_shared_memory.c b/platform/linux-generic/odp_shared_memory.c
index dbaec22..251bf97 100644
--- a/platform/linux-generic/odp_shared_memory.c
+++ b/platform/linux-generic/odp_shared_memory.c
@@ -96,6 +96,14 @@  int odp_shm_init_global(void)
 	return 0;
 }
 
+int odp_shm_term_global(void)
+{
+	int ret = 0;
+
+	ret = munmap(odp_shm_tbl, sizeof(odp_shm_table_t));
+	return ret;
+}
+
 
 int odp_shm_init_local(void)
 {