From 90d9d096bbd2bd8c7935b03be9c40335d7f2452e Mon Sep 17 00:00:00 2001 From: Hallvard Furuseth Date: Mon, 21 Jul 2014 08:12:27 +0200 Subject: [PATCH] mdb_env_set_flags(unopened env): Accept more flags. Useful for maybe-supported flags where mdb_env_open() could EINVAL. --- libraries/liblmdb/lmdb.h | 1 + libraries/liblmdb/mdb.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/liblmdb/lmdb.h b/libraries/liblmdb/lmdb.h index 2374ef7..a6c53a9 100644 --- a/libraries/liblmdb/lmdb.h +++ b/libraries/liblmdb/lmdb.h @@ -727,6 +727,7 @@ void mdb_env_close(MDB_env *env); * This may be used to set some flags in addition to those from * #mdb_env_open(), or to unset these flags. If several threads * change the flags at the same time, the result is undefined. + * Most flags cannot be changed after #mdb_env_open(). * @param[in] env An environment handle returned by #mdb_env_create() * @param[in] flags The flags to change, bitwise OR'ed together * @param[in] onoff A non-zero value sets the flags, zero clears them. diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index 4a21242..3430ec1 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -8715,7 +8715,7 @@ mdb_env_copy(MDB_env *env, const char *path) int ESECT mdb_env_set_flags(MDB_env *env, unsigned int flag, int onoff) { - if ((flag & CHANGEABLE) != flag) + if (flag & (env->me_map ? ~CHANGEABLE : ~(CHANGEABLE|CHANGELESS))) return EINVAL; if (onoff) env->me_flags |= flag;