mdbx: avoid use MREMAP_MAYMOVE for simplification, add TODO.

Change-Id: I6991a411fcced941ef76d58ece608e34e4cdb355
This commit is contained in:
Leonid Yuriev 2019-12-06 21:26:39 +03:00
parent a8da25c9d4
commit 8fed86b368

View File

@ -1525,12 +1525,8 @@ retry_mapview:;
} }
if (limit != map->limit) { if (limit != map->limit) {
#if defined(_GNU_SOURCE) && (defined(__linux__) || defined(__gnu_linux__)) #if defined(MREMAP_MAYMOVE)
void *ptr = mremap(map->address, map->limit, limit, void *ptr = mremap(map->address, map->limit, limit, 0);
/* LY: in case changing the mapping size calling code
must guarantees the absence of competing threads,
and a willingness to another base address */
MREMAP_MAYMOVE);
if (ptr == MAP_FAILED) { if (ptr == MAP_FAILED) {
rc = errno; rc = errno;
return (rc == EAGAIN || rc == ENOMEM) ? MDBX_RESULT_TRUE : rc; return (rc == EAGAIN || rc == ENOMEM) ? MDBX_RESULT_TRUE : rc;
@ -1541,15 +1537,17 @@ retry_mapview:;
#ifdef MADV_DONTFORK #ifdef MADV_DONTFORK
if (unlikely(madvise(map->address, map->limit, MADV_DONTFORK) != 0)) if (unlikely(madvise(map->address, map->limit, MADV_DONTFORK) != 0))
return errno; return errno;
#endif #endif /* MADV_DONTFORK */
#ifdef MADV_NOHUGEPAGE #ifdef MADV_NOHUGEPAGE
(void)madvise(map->address, map->limit, MADV_NOHUGEPAGE); (void)madvise(map->address, map->limit, MADV_NOHUGEPAGE);
#endif #endif /* MADV_NOHUGEPAGE */
#else #else /* MREMAP_MAYMOVE */
/* TODO: Perhaps here it is worth to implement suspend/resume threads
* and perform unmap/map as like for Windows. */
rc = MDBX_RESULT_TRUE; rc = MDBX_RESULT_TRUE;
#endif /* _GNU_SOURCE && __linux__ */ #endif /* !MREMAP_MAYMOVE */
} }
#endif #endif
return rc; return rc;