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;
|
return rc;
|
||||||
#else
|
#else
|
||||||
if (limit != map->length) {
|
if (limit != map->length) {
|
||||||
void *ptr = mremap(map->address, map->length, limit, MREMAP_MAYMOVE);
|
#if defined(_GNU_SOURCE) && !defined(__FreeBSD__)
|
||||||
if (ptr == MAP_FAILED)
|
void *ptr = mremap(map->address, map->length, limit,
|
||||||
return errno;
|
/* 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->address = ptr;
|
||||||
map->length = limit;
|
map->length = limit;
|
||||||
|
#else
|
||||||
|
return MDBX_RESULT_TRUE;
|
||||||
|
#endif /* mremap() <= _GNU_SOURCE && !__FreeBSD__ */
|
||||||
}
|
}
|
||||||
return (flags & MDBX_RDONLY) ? MDBX_SUCCESS : mdbx_ftruncate(map->fd, size);
|
return (flags & MDBX_RDONLY) ? MDBX_SUCCESS : mdbx_ftruncate(map->fd, size);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user