diff mbox

[1/3] linux-generic: shared memory: fix the name composition in odp_shm_free

Message ID 1464865456-29702-1-git-send-email-yi.he@linaro.org
State Accepted
Commit 9d2ee6f85a8ed2502eb1238c39ccb5a6f44d1d87
Headers show

Commit Message

Yi He June 2, 2016, 11:04 a.m. UTC
Fix the name composition in odp_shm_free() as the same
algorithm in odp_shm_reserve(), use IPC namespace if
provided or process ID in default.

Signed-off-by: Yi He <yi.he@linaro.org>
---
 platform/linux-generic/odp_shared_memory.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Comments

Maxim Uvarov June 2, 2016, 2:29 p.m. UTC | #1
Merged,
Maxim.

On 06/02/16 14:04, Yi He wrote:
> Fix the name composition in odp_shm_free() as the same
> algorithm in odp_shm_reserve(), use IPC namespace if
> provided or process ID in default.
>
> Signed-off-by: Yi He <yi.he@linaro.org>
> ---
>   platform/linux-generic/odp_shared_memory.c | 10 ++++++++--
>   1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/platform/linux-generic/odp_shared_memory.c b/platform/linux-generic/odp_shared_memory.c
> index 568711a..f432cf9 100644
> --- a/platform/linux-generic/odp_shared_memory.c
> +++ b/platform/linux-generic/odp_shared_memory.c
> @@ -179,9 +179,15 @@ int odp_shm_free(odp_shm_t shm)
>   	}
>   
>   	if (block->flags & ODP_SHM_PROC || block->flags & _ODP_SHM_PROC_NOCREAT) {
> +		int shm_ns_id;
> +
> +		if (odp_global_data.ipc_ns)
> +			shm_ns_id = odp_global_data.ipc_ns;
> +		else
> +			shm_ns_id = odp_global_data.main_pid;
> +
>   		snprintf(shm_devname, SHM_DEVNAME_MAXLEN,
> -			 SHM_DEVNAME_FORMAT, odp_global_data.main_pid,
> -			 block->name);
> +			 SHM_DEVNAME_FORMAT, shm_ns_id, block->name);
>   		ret = shm_unlink(shm_devname);
>   		if (0 != ret) {
>   			ODP_DBG("odp_shm_free: shm_unlink failed\n");
diff mbox

Patch

diff --git a/platform/linux-generic/odp_shared_memory.c b/platform/linux-generic/odp_shared_memory.c
index 568711a..f432cf9 100644
--- a/platform/linux-generic/odp_shared_memory.c
+++ b/platform/linux-generic/odp_shared_memory.c
@@ -179,9 +179,15 @@  int odp_shm_free(odp_shm_t shm)
 	}
 
 	if (block->flags & ODP_SHM_PROC || block->flags & _ODP_SHM_PROC_NOCREAT) {
+		int shm_ns_id;
+
+		if (odp_global_data.ipc_ns)
+			shm_ns_id = odp_global_data.ipc_ns;
+		else
+			shm_ns_id = odp_global_data.main_pid;
+
 		snprintf(shm_devname, SHM_DEVNAME_MAXLEN,
-			 SHM_DEVNAME_FORMAT, odp_global_data.main_pid,
-			 block->name);
+			 SHM_DEVNAME_FORMAT, shm_ns_id, block->name);
 		ret = shm_unlink(shm_devname);
 		if (0 != ret) {
 			ODP_DBG("odp_shm_free: shm_unlink failed\n");