From c0be0d6fb7b6dfb601bef703d663024bb1ead9f9 Mon Sep 17 00:00:00 2001 From: Leo Yuriev Date: Tue, 9 Jan 2018 21:12:53 +0300 Subject: [PATCH] mdbx: fix mdbx_env_set_geometry() for case remap failed. Change-Id: I0850692737eaee3c7f33194dfa19b88ce74497c8 --- src/mdbx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mdbx.c b/src/mdbx.c index 27f6ec5a..304b8839 100644 --- a/src/mdbx.c +++ b/src/mdbx.c @@ -4523,6 +4523,7 @@ LIBMDBX_API int mdbx_env_set_geometry(MDBX_env *env, intptr_t size_lower, shrink_threshold = 1; #endif + bool need_unlock = false; int rc = MDBX_PROBLEM; if (env->me_map) { /* env already mapped */ @@ -4533,6 +4534,7 @@ LIBMDBX_API int mdbx_env_set_geometry(MDBX_env *env, intptr_t size_lower, int err = mdbx_txn_lock(env, false); if (unlikely(err != MDBX_SUCCESS)) return err; + need_unlock = true; } MDBX_meta *head = mdbx_meta_head(env); @@ -4721,7 +4723,7 @@ LIBMDBX_API int mdbx_env_set_geometry(MDBX_env *env, intptr_t size_lower, } bailout: - if (env->me_map && !inside_txn) + if (need_unlock) mdbx_txn_unlock(env); return rc; }