mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-30 22:47:16 +08:00
mdbx: portability - allows operation without mremap().
Change-Id: I7fed42d51259e582e9dbc401c78f7f829a80f71c
This commit is contained in:
parent
97e4f66d16
commit
41f00485fd
16
src/osal.c
16
src/osal.c
@ -1147,11 +1147,21 @@ retry_mapview:;
|
||||
return rc;
|
||||
#else
|
||||
if (limit != map->length) {
|
||||
void *ptr = mremap(map->address, map->length, limit, MREMAP_MAYMOVE);
|
||||
if (ptr == MAP_FAILED)
|
||||
return errno;
|
||||
#if defined(_GNU_SOURCE) && !defined(__FreeBSD__)
|
||||
void *ptr = mremap(map->address, map->length, limit,
|
||||
/* 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) {
|
||||
int err = errno;
|
||||
return (err == EAGAIN || err == ENOMEM) ? MDBX_RESULT_TRUE : err;
|
||||
}
|
||||
map->address = ptr;
|
||||
map->length = limit;
|
||||
#else
|
||||
return MDBX_RESULT_TRUE;
|
||||
#endif /* mremap() <= _GNU_SOURCE && !__FreeBSD__ */
|
||||
}
|
||||
return (flags & MDBX_RDONLY) ? MDBX_SUCCESS : mdbx_ftruncate(map->fd, size);
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user