From f73994054779be3e177bfd27f44fcd3147e7d08d Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Tue, 1 Oct 2013 13:16:38 -0700 Subject: [PATCH] Add MDB_NORDLOCK to omit all reader table usage Calling app wants to manage its own locking. --- libraries/liblmdb/lmdb.h | 2 ++ libraries/liblmdb/mdb.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/libraries/liblmdb/lmdb.h b/libraries/liblmdb/lmdb.h index f637229..848ba63 100644 --- a/libraries/liblmdb/lmdb.h +++ b/libraries/liblmdb/lmdb.h @@ -269,6 +269,8 @@ typedef void (MDB_rel_func)(MDB_val *item, void *oldptr, void *newptr, void *rel #define MDB_MAPASYNC 0x100000 /** tie reader locktable slots to #MDB_txn objects instead of to threads */ #define MDB_NOTLS 0x200000 + /** don't use reader locktable at all, caller must manage read/write concurrency */ +#define MDB_NORDLOCK 0x400000 /** @} */ /** @defgroup mdb_dbi_open Database Flags diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index c4db089..e82335d 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -3983,7 +3983,7 @@ mdb_env_open(MDB_env *env, const char *path, unsigned int flags, mdb_mode_t mode goto leave; } - if (F_ISSET(flags, MDB_RDONLY)) { + if ((flags & (MDB_RDONLY|MDB_NORDLOCK)) == MDB_RDONLY) { rc = mdb_env_setup_locks(env, lpath, mode, &excl); if (rc) goto leave;