mdbx: fix posix mdbx_lck_destroy().

This commit is contained in:
Leo Yuriev 2017-04-05 16:34:19 +03:00
parent f51c8dae72
commit fcb63130d6
2 changed files with 7 additions and 3 deletions

View File

@ -89,7 +89,7 @@ bailout:
void mdbx_lck_destroy(MDB_env *env) { void mdbx_lck_destroy(MDB_env *env) {
if (env->me_lfd != INVALID_HANDLE_VALUE) { if (env->me_lfd != INVALID_HANDLE_VALUE) {
/* try get exclusive access */ /* try get exclusive access */
if (mdbx_lck_op(env->me_lfd, F_SETLK, F_WRLCK, 0) == 0) { if (env->me_txns && mdbx_lck_op(env->me_lfd, F_SETLK, F_WRLCK, 0) == 0) {
/* got exclusive, drown mutexes */ /* got exclusive, drown mutexes */
int rc = pthread_mutex_destroy(&env->me_txns->mti_rmutex); int rc = pthread_mutex_destroy(&env->me_txns->mti_rmutex);
if (rc == 0) if (rc == 0)

View File

@ -4160,8 +4160,10 @@ static void __cold mdbx_env_close0(MDB_env *env) {
env->me_valgrind_handle = -1; env->me_valgrind_handle = -1;
#endif #endif
} }
if (env->me_fd != INVALID_HANDLE_VALUE) if (env->me_fd != INVALID_HANDLE_VALUE) {
(void)mdbx_closefile(env->me_fd); (void)mdbx_closefile(env->me_fd);
env->me_fd = INVALID_HANDLE_VALUE;
}
mdbx_munmap((void *)env->me_txns, mdbx_munmap((void *)env->me_txns,
(env->me_maxreaders - 1) * sizeof(MDB_reader) + (env->me_maxreaders - 1) * sizeof(MDB_reader) +
@ -4169,8 +4171,10 @@ static void __cold mdbx_env_close0(MDB_env *env) {
env->me_txns = NULL; env->me_txns = NULL;
env->me_pid = 0; env->me_pid = 0;
if (env->me_lfd != INVALID_HANDLE_VALUE) if (env->me_lfd != INVALID_HANDLE_VALUE) {
(void)mdbx_closefile(env->me_lfd); (void)mdbx_closefile(env->me_lfd);
env->me_lfd = INVALID_HANDLE_VALUE;
}
} }
int __cold mdbx_env_close_ex(MDB_env *env, int dont_sync) { int __cold mdbx_env_close_ex(MDB_env *env, int dont_sync) {