From 2806453b54b4e8017d403fb597ccb4e25c207c89 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Thu, 2 Jun 2016 21:01:27 +0100 Subject: [PATCH] mdbx: backport - ITS#8339 Solaris 10/11 robust mutex fixes. Check for PTHREAD_MUTEX_ROBUST_NP definition (this doesn't work on Linux/glibc because they used an enum). Zero out mutex before initing. Change-Id: Ic618a6a72fbd7680dd76d5fd0aef06545dcba994 --- mdb.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mdb.c b/mdb.c index 6eacceab..8f5496df 100644 --- a/mdb.c +++ b/mdb.c @@ -4815,8 +4815,14 @@ mdb_env_setup_locks(MDB_env *env, char *lpath, int mode, int *excl) return errno; if (*excl > 0) { - pthread_mutexattr_t mattr; + /* Solaris needs this before initing a robust mutex. Otherwise + * it may skip the init and return EBUSY "seems someone already + * inited" or EINVAL "it was inited differently". + */ + memset(&env->me_txns->mti_rmutex, 0, sizeof(env->me_txns->mti_rmutex)); + 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)) #if MDB_USE_ROBUST