mirror of
https://github.com/isar/libmdbx.git
synced 2025-02-01 06:58:21 +08:00
mdbx: fix madvise() flags, it is not a bitmask.
Change-Id: Ie5109779dc596190c467dcd6e84a1684e71575f5
This commit is contained in:
parent
0e508f0d3b
commit
425ac1cde6
19
mdb.c
19
mdb.c
@ -4288,15 +4288,24 @@ mdb_env_map(MDB_env *env, void *addr)
|
||||
return errno;
|
||||
}
|
||||
|
||||
unsigned madvise_flags = MADV_DONTFORK;
|
||||
if (flags & MDB_NORDAHEAD)
|
||||
if (flags & MDB_NORDAHEAD) {
|
||||
/* Turn off readahead. It's harmful when the DB is larger than RAM. */
|
||||
madvise_flags |= MADV_RANDOM;
|
||||
if (madvise(env->me_map, env->me_mapsize, madvise_flags))
|
||||
if (madvise(env->me_map, env->me_mapsize, MADV_RANDOM) < 0)
|
||||
return errno;
|
||||
}
|
||||
|
||||
if (madvise(env->me_map, env->me_mapsize, MADV_DONTFORK) < 0)
|
||||
return errno;
|
||||
|
||||
if (madvise(env->me_map, env->me_mapsize, MADV_WILLNEED) < 0)
|
||||
return errno;
|
||||
|
||||
#ifdef MADV_NOHUGEPAGE
|
||||
(void) madvise(env->me_map, env->me_mapsize, MADV_NOHUGEPAGE);
|
||||
#endif
|
||||
|
||||
#ifdef MADV_DONTDUMP
|
||||
madvise(env->me_map, env->me_mapsize, MADV_DONTDUMP);
|
||||
(void) madvise(env->me_map, env->me_mapsize, MADV_DONTDUMP);
|
||||
#endif
|
||||
|
||||
/* Can happen because the address argument to mmap() is just a
|
||||
|
Loading…
x
Reference in New Issue
Block a user