ITS#9118 add MAP_NOSYNC for FreeBSD

mdb.master
Howard Chu 5 years ago
parent c3e6b4209e
commit 522c62035c
  1. 11
      libraries/liblmdb/mdb.c

@ -4396,22 +4396,27 @@ mdb_env_map(MDB_env *env, void *addr)
return mdb_nt2win32(rc); return mdb_nt2win32(rc);
env->me_map = map; env->me_map = map;
#else #else
int mmap_flags = MAP_SHARED;
int prot = PROT_READ;
#ifdef MAP_NOSYNC /* Used on FreeBSD */
if (flags & MDB_NOSYNC)
mmap_flags |= MAP_NOSYNC;
#endif
#ifdef MDB_VL32 #ifdef MDB_VL32
(void) flags; (void) flags;
env->me_map = mmap(addr, NUM_METAS * env->me_psize, PROT_READ, MAP_SHARED, env->me_map = mmap(addr, NUM_METAS * env->me_psize, prot, mmap_flags,
env->me_fd, 0); env->me_fd, 0);
if (env->me_map == MAP_FAILED) { if (env->me_map == MAP_FAILED) {
env->me_map = NULL; env->me_map = NULL;
return ErrCode(); return ErrCode();
} }
#else #else
int prot = PROT_READ;
if (flags & MDB_WRITEMAP) { if (flags & MDB_WRITEMAP) {
prot |= PROT_WRITE; prot |= PROT_WRITE;
if (ftruncate(env->me_fd, env->me_mapsize) < 0) if (ftruncate(env->me_fd, env->me_mapsize) < 0)
return ErrCode(); return ErrCode();
} }
env->me_map = mmap(addr, env->me_mapsize, prot, MAP_SHARED, env->me_map = mmap(addr, env->me_mapsize, prot, mmap_flags,
env->me_fd, 0); env->me_fd, 0);
if (env->me_map == MAP_FAILED) { if (env->me_map == MAP_FAILED) {
env->me_map = NULL; env->me_map = NULL;

Loading…
Cancel
Save