env_dpdk/init: remove shared memory files at exit
In multiprocess applications some shared memory files are left around after a primary process exits because they can be used by secondary processes to init memory. However, all primary dpdk processes create these folders so we need to delete them after a single process spdk application exits. Change-Id: If51be95811fb66632316ae260762e5291641b537 Signed-off-by: Seth Howell <seth.howell@intel.com> Reviewed-on: https://review.gerrithub.io/381721 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
36f9d416a1
commit
3da8f166d4
@ -95,6 +95,22 @@ _sprintf_alloc(const char *format, ...)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
spdk_env_delete_shared_files(void)
|
||||
{
|
||||
char buffer[PATH_MAX];
|
||||
|
||||
snprintf(buffer, PATH_MAX, "/var/run/.spdk_pid%d_config", getpid());
|
||||
if (remove(buffer)) {
|
||||
fprintf(stderr, "Unable to remove shared memory file: %s. Error code: %d\n", buffer, errno);
|
||||
}
|
||||
|
||||
snprintf(buffer, PATH_MAX, "/var/run/.spdk_pid%d_hugepage_info", getpid());
|
||||
if (remove(buffer)) {
|
||||
fprintf(stderr, "Unable to remove shared memory file: %s. Error code: %d\n", buffer, errno);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
spdk_env_opts_init(struct spdk_env_opts *opts)
|
||||
{
|
||||
@ -284,6 +300,18 @@ void spdk_env_init(const struct spdk_env_opts *opts)
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
/* If the shared memory id is less than 0, that means that we are
|
||||
* starting a single process application. There will be no other
|
||||
* processes relying on the shared configuration files created by
|
||||
* dpdk for this process, and they can be deleted upon exit.
|
||||
* Specifying a shared memory id >= 0 implies that there will be multiple
|
||||
* processes relying on those configuration files, and we cannot delete
|
||||
* them when this process exits.
|
||||
*/
|
||||
if (opts->shm_id < 0) {
|
||||
atexit(spdk_env_delete_shared_files);
|
||||
}
|
||||
|
||||
spdk_mem_map_init();
|
||||
spdk_vtophys_init();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user