From: Howard Chu Date: Fri, 9 Jan 2015 11:25:07 +0000 (+0000) Subject: ITS#8021 env_sync is invalid in RDONLY env X-Git-Tag: LMDB_0.9.15~38 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=0b9f42d1f4c2b36ab1e44ca7e62fddc0abc300a2;p=openldap ITS#8021 env_sync is invalid in RDONLY env --- diff --git a/libraries/liblmdb/lmdb.h b/libraries/liblmdb/lmdb.h index 408b6ed0ea..35f5f420e3 100644 --- a/libraries/liblmdb/lmdb.h +++ b/libraries/liblmdb/lmdb.h @@ -698,7 +698,8 @@ int mdb_env_info(MDB_env *env, MDB_envinfo *stat); * Data is always written to disk when #mdb_txn_commit() is called, * but the operating system may keep it buffered. LMDB always flushes * the OS buffers upon commit as well, unless the environment was - * opened with #MDB_NOSYNC or in part #MDB_NOMETASYNC. + * opened with #MDB_NOSYNC or in part #MDB_NOMETASYNC. This call is + * not valid if the environment was opened with #MDB_RDONLY. * @param[in] env An environment handle returned by #mdb_env_create() * @param[in] force If non-zero, force a synchronous flush. Otherwise * if the environment has the #MDB_NOSYNC flag set the flushes @@ -706,6 +707,7 @@ int mdb_env_info(MDB_env *env, MDB_envinfo *stat); * @return A non-zero error value on failure and 0 on success. Some possible * errors are: * diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index 264c15fc9f..a575768508 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -2305,6 +2305,8 @@ int mdb_env_sync(MDB_env *env, int force) { int rc = 0; + if (env->me_flags & MDB_RDONLY) + return EACCES; if (force || !F_ISSET(env->me_flags, MDB_NOSYNC)) { if (env->me_flags & MDB_WRITEMAP) { int flags = ((env->me_flags & MDB_MAPASYNC) && !force)