Hi Hallvard
Thanks for the hint. Your are perfectly right, the mutex memory has to be zeroed in case of a robust mutex. Applied against 0.9.18 and it seems to work. My proposed patch is broken.
There is a slight inconsistency if subsequent calls after a successfull pthread_mutexattr_init() fail (in the ORed if statement). This might result in a memory leak as the mutex attributes are not destroyed. But this is not related to the topic of this ITS.
Thank you
Rolf
On 06/02/16 07:56 AM, Hallvard Breien Furuseth wrote:
Rolf, please try this instead, like the manpage you referred to says under Notes. Do not catch EBUSY/EINVAL, they do mean the mutex was not (re)inited.
diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index 0209c09..5ae93bc 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -304,7 +304,7 @@ union semun { # else # define MDB_USE_ROBUST 1 /* glibc < 2.12 only provided _np API */ -# if defined(__GLIBC__) && GLIBC_VER < 0x02000c +# if (defined(__GLIBC__) && GLIBC_VER < 0x02000c) || defined(__SunOS_5_10) # define PTHREAD_MUTEX_ROBUST PTHREAD_MUTEX_ROBUST_NP # define pthread_mutexattr_setrobust(attr, flag) pthread_mutexattr_setrobust_np(attr, flag) # define pthread_mutex_consistent(mutex) pthread_mutex_consistent_np(mutex) @@ -4963,6 +4963,13 @@ mdb_env_setup_locks(MDB_env *env, char *lpath, int mode, int *excl) #else /* MDB_USE_POSIX_MUTEX: */ 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));
- if ((rc = pthread_mutexattr_init(&mattr)) || (rc = pthread_mutexattr_setpshared(&mattr, PTHREAD_PROCESS_SHARED)) #ifdef MDB_ROBUST_SUPPORTED