mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-04 16:54:13 +08:00
mdbx: minor refine mdbx_mmap().
Change-Id: Ic5026b6412ca93a00faeb8306975d896d85b475d
This commit is contained in:
parent
f57931f614
commit
1f7f3af16c
@ -4189,10 +4189,8 @@ bailout:
|
||||
static int __cold mdbx_env_map(MDBX_env *env, size_t usedsize) {
|
||||
int rc = mdbx_mmap(env->me_flags, &env->me_dxb_mmap, env->me_dbgeo.now,
|
||||
env->me_dbgeo.upper);
|
||||
if (unlikely(rc != MDBX_SUCCESS)) {
|
||||
env->me_map = NULL;
|
||||
if (unlikely(rc != MDBX_SUCCESS))
|
||||
return rc;
|
||||
}
|
||||
|
||||
#ifdef MADV_DONTFORK
|
||||
if (madvise(env->me_map, env->me_mapsize, MADV_DONTFORK))
|
||||
@ -5125,10 +5123,8 @@ static void __cold mdbx_env_close0(MDBX_env *env) {
|
||||
env->me_fd = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
if (env->me_lck) {
|
||||
if (env->me_lck)
|
||||
mdbx_munmap(&env->me_lck_mmap);
|
||||
env->me_lck = nullptr;
|
||||
}
|
||||
env->me_pid = 0;
|
||||
env->me_oldest = nullptr;
|
||||
|
||||
|
@ -781,7 +781,7 @@ int mdbx_mmap(int flags, mdbx_mmap_t *map, size_t must, size_t limit) {
|
||||
map->length = 0;
|
||||
map->current = 0;
|
||||
map->section = NULL;
|
||||
map->address = MAP_FAILED;
|
||||
map->address = nullptr;
|
||||
|
||||
if (GetFileType(map->fd) != FILE_TYPE_DISK)
|
||||
return ERROR_FILE_OFFLINE;
|
||||
@ -874,7 +874,7 @@ int mdbx_mmap(int flags, mdbx_mmap_t *map, size_t must, size_t limit) {
|
||||
if (!NT_SUCCESS(rc))
|
||||
return ntstatus2errcode(rc);
|
||||
|
||||
map->address = NULL;
|
||||
map->address = nullptr;
|
||||
SIZE_T ViewSize = (flags & MDBX_RDONLY) ? must : limit;
|
||||
rc = NtMapViewOfSection(
|
||||
map->section, GetCurrentProcess(), &map->address,
|
||||
@ -889,7 +889,7 @@ int mdbx_mmap(int flags, mdbx_mmap_t *map, size_t must, size_t limit) {
|
||||
if (!NT_SUCCESS(rc)) {
|
||||
NtClose(map->section);
|
||||
map->section = 0;
|
||||
map->address = MAP_FAILED;
|
||||
map->address = nullptr;
|
||||
return ntstatus2errcode(rc);
|
||||
}
|
||||
|
||||
@ -907,6 +907,7 @@ int mdbx_mmap(int flags, mdbx_mmap_t *map, size_t must, size_t limit) {
|
||||
return MDBX_SUCCESS;
|
||||
}
|
||||
map->length = 0;
|
||||
map->address = nullptr;
|
||||
return errno;
|
||||
#endif
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user