mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-04 17:14:12 +08:00
mdbx: check for running write-txn inside mdbx_env_close().
This commit is contained in:
parent
b1c7fa30c0
commit
3e9308eb0e
2
mdbx.h
2
mdbx.h
@ -754,7 +754,7 @@ LIBMDBX_API int mdbx_env_sync(MDBX_env *env, int force);
|
|||||||
* ignored on opening next time, and transactions since the
|
* ignored on opening next time, and transactions since the
|
||||||
* last non-weak checkpoint (meta-page update) will rolledback
|
* last non-weak checkpoint (meta-page update) will rolledback
|
||||||
* for consistency guarantee. */
|
* for consistency guarantee. */
|
||||||
LIBMDBX_API void mdbx_env_close(MDBX_env *env);
|
LIBMDBX_API int mdbx_env_close(MDBX_env *env);
|
||||||
|
|
||||||
/* Set environment flags.
|
/* Set environment flags.
|
||||||
*
|
*
|
||||||
|
10
src/mdbx.c
10
src/mdbx.c
@ -5387,8 +5387,12 @@ int __cold mdbx_env_close_ex(MDBX_env *env, int dont_sync) {
|
|||||||
if (unlikely(env->me_signature != MDBX_ME_SIGNATURE))
|
if (unlikely(env->me_signature != MDBX_ME_SIGNATURE))
|
||||||
return MDBX_EBADSIGN;
|
return MDBX_EBADSIGN;
|
||||||
|
|
||||||
if (!dont_sync && !(env->me_flags & MDBX_RDONLY))
|
if ((env->me_flags & MDBX_RDONLY) == 0) {
|
||||||
rc = mdbx_env_sync(env, true);
|
if (env->me_txn0->mt_owner && env->me_txn0->mt_owner != mdbx_thread_self())
|
||||||
|
return MDBX_BUSY;
|
||||||
|
if (!dont_sync)
|
||||||
|
rc = mdbx_env_sync(env, true);
|
||||||
|
}
|
||||||
|
|
||||||
VALGRIND_DESTROY_MEMPOOL(env);
|
VALGRIND_DESTROY_MEMPOOL(env);
|
||||||
while ((dp = env->me_dpages) != NULL) {
|
while ((dp = env->me_dpages) != NULL) {
|
||||||
@ -5406,7 +5410,7 @@ int __cold mdbx_env_close_ex(MDBX_env *env, int dont_sync) {
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __cold mdbx_env_close(MDBX_env *env) { mdbx_env_close_ex(env, 0); }
|
int mdbx_env_close(MDBX_env *env) { return mdbx_env_close_ex(env, 0); }
|
||||||
|
|
||||||
/* Compare two items pointing at aligned unsigned int's. */
|
/* Compare two items pointing at aligned unsigned int's. */
|
||||||
static int __hot mdbx_cmp_int_ai(const MDBX_val *a, const MDBX_val *b) {
|
static int __hot mdbx_cmp_int_ai(const MDBX_val *a, const MDBX_val *b) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user