mdbx: minor clarify mdbx_env_set_geometry().

This commit is contained in:
Leo Yuriev 2017-12-19 15:33:25 +03:00
parent 46a3d4e0a3
commit a5b077b2f0

View File

@ -4444,8 +4444,8 @@ LIBMDBX_API int mdbx_env_set_geometry(MDBX_env *env, intptr_t size_lower,
if (unlikely(env->me_signature != MDBX_ME_SIGNATURE)) if (unlikely(env->me_signature != MDBX_ME_SIGNATURE))
return MDBX_EBADSIGN; return MDBX_EBADSIGN;
const bool outside_txn = const bool inside_txn =
(!env->me_txn0 || env->me_txn0->mt_owner != mdbx_thread_self()); (env->me_txn0 && env->me_txn0->mt_owner == mdbx_thread_self());
#if MDBX_DEBUG #if MDBX_DEBUG
if (growth_step < 0) if (growth_step < 0)
@ -4460,7 +4460,7 @@ LIBMDBX_API int mdbx_env_set_geometry(MDBX_env *env, intptr_t size_lower,
if (!env->me_lck || (env->me_flags & MDBX_RDONLY)) if (!env->me_lck || (env->me_flags & MDBX_RDONLY))
return MDBX_EACCESS; return MDBX_EACCESS;
if (outside_txn) { if (!inside_txn) {
int err = mdbx_txn_lock(env, false); int err = mdbx_txn_lock(env, false);
if (unlikely(err != MDBX_SUCCESS)) if (unlikely(err != MDBX_SUCCESS))
return err; return err;
@ -4501,10 +4501,8 @@ LIBMDBX_API int mdbx_env_set_geometry(MDBX_env *env, intptr_t size_lower,
#endif /* Windows */ #endif /* Windows */
} else { } else {
/* env NOT yet mapped */ /* env NOT yet mapped */
if (!outside_txn) { if (unlikely(inside_txn))
rc = MDBX_PANIC; return MDBX_PANIC;
goto bailout;
}
if (pagesize < 0) { if (pagesize < 0) {
pagesize = env->me_os_psize; pagesize = env->me_os_psize;
@ -4660,7 +4658,7 @@ LIBMDBX_API int mdbx_env_set_geometry(MDBX_env *env, intptr_t size_lower,
} }
bailout: bailout:
if (env->me_map && outside_txn) if (env->me_map && !inside_txn)
mdbx_txn_unlock(env); mdbx_txn_unlock(env);
return rc; return rc;
} }