{
RTE_LOG(DEBUG, EAL,
"Restoring previous memory policy: %d\n", *oldpolicy);
- if (oldpolicy == MPOL_DEFAULT) {
+ if (*oldpolicy == MPOL_DEFAULT) {
numa_set_localalloc();
} else if (set_mempolicy(*oldpolicy, oldmask->maskp,
oldmask->size + 1) < 0) {
*/
void *va = mmap(addr, alloc_sz, PROT_READ | PROT_WRITE,
MAP_SHARED | MAP_POPULATE | MAP_FIXED, fd, map_offset);
- /* for non-single file segments, we can close fd here */
- if (!internal_config.single_file_segments)
- close(fd);
if (va == MAP_FAILED) {
RTE_LOG(DEBUG, EAL, "%s(): mmap() failed: %s\n", __func__,
}
if (va != addr) {
RTE_LOG(DEBUG, EAL, "%s(): wrong mmap() address\n", __func__);
- goto mapped;
+ munmap(va, alloc_sz);
+ goto resized;
}
rte_iova_t iova = rte_mem_virt2iova(addr);
(unsigned int)(alloc_sz >> 20));
goto mapped;
}
+ /* for non-single file segments, we can close fd here */
+ if (!internal_config.single_file_segments)
+ close(fd);
+
*(int *)addr = *(int *)addr;
ms->addr = addr;
resize_hugefile(fd, map_offset, alloc_sz, false);
if (is_zero_length(fd)) {
struct msl_entry *te = get_msl_entry_by_idx(list_idx);
- if (te != NULL && te->fd >= 0) {
- close(te->fd);
+ /* te->fd is equivalent to fd */
+ if (te != NULL && te->fd >= 0)
te->fd = -1;
- }
/* ignore errors, can't make it any worse */
unlink(path);
+ close(fd);
}
+ /* if we're not removing the file, fd stays in the tailq */
} else {
close(fd);
unlink(path);
*/
if (is_zero_length(fd)) {
struct msl_entry *te = get_msl_entry_by_idx(list_idx);
- if (te != NULL && te->fd >= 0) {
- close(te->fd);
+ /* te->fd is equivalent to fd */
+ if (te != NULL && te->fd >= 0)
te->fd = -1;
- }
unlink(path);
+ close(fd);
}
+ /* if we're not removing the file, fd stays in the tailq */
ret = 0;
} else {
/* if we're able to take out a write lock, we're the last one