From 34f572e7a52ffc394040e13e6d14b368176b2b09 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Thu, 21 Nov 2019 20:44:37 +0000 Subject: [PATCH] ITS#9118 add MAP_NOSYNC for FreeBSD --- libraries/liblmdb/mdb.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index 692feaa..67a739a 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -4010,13 +4010,18 @@ mdb_env_map(MDB_env *env, void *addr) if (rc) return rc; #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 if (flags & MDB_WRITEMAP) { prot |= PROT_WRITE; if (ftruncate(env->me_fd, env->me_mapsize) < 0) 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); if (env->me_map == MAP_FAILED) { env->me_map = NULL;