mdbx: backport - mdb_env_setup_locks() Plug mutexattr leak on error.

Change-Id: Iac82f957e4961ec964d9d0a75ef0b24a9f68929c
This commit is contained in:
Hallvard Furuseth 2016-06-05 23:42:44 +02:00 committed by Leo Yuriev
parent 2806453b54
commit f5c61018ba

16
mdb.c
View File

@ -4823,15 +4823,19 @@ mdb_env_setup_locks(MDB_env *env, char *lpath, int mode, int *excl)
memset(&env->me_txns->mti_wmutex, 0, sizeof(env->me_txns->mti_wmutex));
pthread_mutexattr_t mattr;
if ((rc = pthread_mutexattr_init(&mattr))
|| (rc = pthread_mutexattr_setpshared(&mattr, PTHREAD_PROCESS_SHARED))
rc = pthread_mutexattr_init(&mattr);
if (rc) return rc;
rc = pthread_mutexattr_setpshared(&mattr, PTHREAD_PROCESS_SHARED);
#if MDB_USE_ROBUST
|| (rc = pthread_mutexattr_setrobust(&mattr, PTHREAD_MUTEX_ROBUST))
if(! rc) rc = pthread_mutexattr_setrobust(&mattr, PTHREAD_MUTEX_ROBUST);
#endif /* MDB_USE_ROBUST */
|| (rc = pthread_mutex_init(&env->me_txns->mti_rmutex, &mattr))
|| (rc = pthread_mutex_init(&env->me_txns->mti_wmutex, &mattr)))
return rc;
if (! rc) rc = pthread_mutex_init(&env->me_txns->mti_rmutex, &mattr);
if (! rc) rc = pthread_mutex_init(&env->me_txns->mti_wmutex, &mattr);
pthread_mutexattr_destroy(&mattr);
if (rc) return rc;
env->me_txns->mti_magic = MDB_MAGIC;
env->me_txns->mti_format = MDB_LOCK_FORMAT;