This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "".
The branch, api-next has been updated via b843386fb4f62585c637bc81e04c0b44fa907aab (commit) from f6772a1c2c86c1982d68fc50480748751ac36e98 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- commit b843386fb4f62585c637bc81e04c0b44fa907aab Author: Christophe Milard christophe.milard@linaro.org Date: Tue Dec 6 18:25:32 2016 +0100
linux-gen: _ishm: unlinking files asap for cleaner termination
_ishm now unlinks the created files as soon as possible, hence reducing the chance to see left-overs, if ODP terminates abnormaly. This does not provide 100% guaranty: if we are unlucky enough, ODP may be killed between open() and unlink(). Also this method excludes exported files (flag _ODP_ISHM_EXPORT), whose names shall be seen in the file system.
Signed-off-by: Christophe Milard christophe.milard@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/_ishm.c b/platform/linux-generic/_ishm.c index 449e357..efdb7bc 100644 --- a/platform/linux-generic/_ishm.c +++ b/platform/linux-generic/_ishm.c @@ -71,6 +71,7 @@ #include <sys/types.h> #include <inttypes.h> #include <sys/wait.h> +#include <libgen.h>
/* * Maximum number of internal shared memory blocks. @@ -159,6 +160,7 @@ typedef struct ishm_block { char exptname[ISHM_FILENAME_MAXLEN]; /* name of the export file */ uint32_t user_flags; /* any flags the user want to remember. */ uint32_t flags; /* block creation flags. */ + uint32_t external_fd:1; /* block FD was externally provided */ uint64_t user_len; /* length, as requested at reserve time. */ void *start; /* only valid if _ODP_ISHM_SINGLE_VA is set*/ uint64_t len; /* length. multiple of page size. 0 if free*/ @@ -452,15 +454,17 @@ static int create_file(int block_index, huge_flag_t huge, uint64_t len, ODP_ERR("ftruncate failed: fd=%d, err=%s.\n", fd, strerror(errno)); close(fd); + unlink(filename); return -1; }
- strncpy(new_block->filename, filename, ISHM_FILENAME_MAXLEN - 1);
/* if _ODP_ISHM_EXPORT is set, create a description file for * external ref: */ if (flags & _ODP_ISHM_EXPORT) { + strncpy(new_block->filename, filename, + ISHM_FILENAME_MAXLEN - 1); snprintf(new_block->exptname, ISHM_FILENAME_MAXLEN, ISHM_EXPTNAME_FORMAT, odp_global_data.main_pid, @@ -483,6 +487,8 @@ static int create_file(int block_index, huge_flag_t huge, uint64_t len, } } else { new_block->exptname[0] = 0; + /* remove the file from the filesystem, keeping its fd open */ + unlink(filename); }
return fd; @@ -814,6 +820,9 @@ int _odp_ishm_reserve(const char *name, uint64_t size, int fd, return -1; } new_block->huge = EXTERNAL; + new_block->external_fd = 1; + } else { + new_block->external_fd = 0; }
/* Otherwise, Try first huge pages when possible and needed: */ @@ -865,8 +874,9 @@ int _odp_ishm_reserve(const char *name, uint64_t size, int fd,
/* if neither huge pages or normal pages works, we cannot proceed: */ if ((fd < 0) || (addr == NULL) || (len == 0)) { - if ((new_block->filename[0]) && (fd >= 0)) + if ((!new_block->external_fd) && (fd >= 0)) close(fd); + delete_file(new_block); odp_spinlock_unlock(&ishm_tbl->lock); ODP_ERR("_ishm_reserve failed.\n"); return -1;
-----------------------------------------------------------------------
Summary of changes: platform/linux-generic/_ishm.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
hooks/post-receive