aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Uvarov <maxim.uvarov@linaro.org>2017-07-19 15:51:55 +0000
committerMaxim Uvarov <maxim.uvarov@linaro.org>2017-07-21 14:58:29 +0300
commit063d713d0c167c56b4497be566b2310a5a2daf42 (patch)
tree8a46c9b405620cb34b1fc724374a1f0740f83c1a
parent3eeb249a4774f12d2d16ca349a591654eae620ae (diff)
linux-gen: ishm fix defining directory for shm files
Code missed getenv() return code check and did not use value of env variable to change default derection. Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org> Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org>
-rw-r--r--platform/linux-generic/_ishm.c15
-rw-r--r--platform/linux-generic/include/odp_internal.h1
2 files changed, 12 insertions, 4 deletions
diff --git a/platform/linux-generic/_ishm.c b/platform/linux-generic/_ishm.c
index cde2dbc3b..892e889bf 100644
--- a/platform/linux-generic/_ishm.c
+++ b/platform/linux-generic/_ishm.c
@@ -1442,9 +1442,15 @@ int _odp_ishm_init_global(void)
odp_global_data.main_pid = getpid();
odp_global_data.shm_dir = getenv("ODP_SHM_DIR");
- odp_global_data.shm_dir =
- calloc(1, sizeof(ISHM_FILENAME_NORMAL_PAGE_DIR));
- sprintf(odp_global_data.shm_dir, "%s", ISHM_FILENAME_NORMAL_PAGE_DIR);
+ if (odp_global_data.shm_dir) {
+ odp_global_data.shm_dir_from_env = 1;
+ } else {
+ odp_global_data.shm_dir =
+ calloc(1, sizeof(ISHM_FILENAME_NORMAL_PAGE_DIR));
+ sprintf(odp_global_data.shm_dir, "%s",
+ ISHM_FILENAME_NORMAL_PAGE_DIR);
+ odp_global_data.shm_dir_from_env = 0;
+ }
ODP_DBG("ishm: using dir %s\n", odp_global_data.shm_dir);
@@ -1661,7 +1667,8 @@ int _odp_ishm_term_global(void)
if (_odp_ishmphy_unbook_va())
ret |= -1;
- free(odp_global_data.shm_dir);
+ if (!odp_global_data.shm_dir_from_env)
+ free(odp_global_data.shm_dir);
return ret;
}
diff --git a/platform/linux-generic/include/odp_internal.h b/platform/linux-generic/include/odp_internal.h
index dd3374b7f..ec17b1992 100644
--- a/platform/linux-generic/include/odp_internal.h
+++ b/platform/linux-generic/include/odp_internal.h
@@ -43,6 +43,7 @@ typedef struct {
struct odp_global_data_s {
char *shm_dir; /*< directory for odp mmaped files */
+ int shm_dir_from_env; /*< overload default with env */
pid_t main_pid;
char uid[UID_MAXLEN];
odp_log_func_t log_fn;