From: Hallvard Furuseth Date: Fri, 3 Jul 2015 21:07:00 +0000 (+0200) Subject: Add MDB_USE_POSIX_MUTEX. X-Git-Tag: LMDB_0.9.17~81 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=3a71450436b7a53b90032f8606a37269fd90ffa8;p=openldap Add MDB_USE_POSIX_MUTEX. So far just to help aligning mdb.master and mdb.RE. We'll make it an option later. --- diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index 440966b9ef..1cd915042d 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -121,7 +121,14 @@ extern int cacheflush(char *addr, int nbytes, int cache); #ifdef MDB_USE_POSIX_SEM # define MDB_USE_HASH 1 #include +#else +#define MDB_USE_POSIX_MUTEX 1 +#endif #endif + +#if defined(_WIN32) + defined(MDB_USE_POSIX_SEM) \ + + defined(MDB_USE_POSIX_MUTEX) != 1 +# error "Ambiguous shared-lock implementation" #endif #ifdef USE_VALGRIND @@ -278,7 +285,7 @@ mdb_sem_wait(sem_t *sem) return rc; } -#else +#else /* MDB_USE_POSIX_MUTEX: */ /** Lock the reader mutex. */ #define LOCK_MUTEX_R(env) pthread_mutex_lock(&(env)->me_txns->mti_mutex) @@ -1219,7 +1226,7 @@ static int mdb_page_split(MDB_cursor *mc, MDB_val *newkey, MDB_val *newdata, static int mdb_env_read_header(MDB_env *env, MDB_meta *meta); static int mdb_env_pick_meta(const MDB_env *env); static int mdb_env_write_meta(MDB_txn *txn); -#if !(defined(_WIN32) || defined(MDB_USE_POSIX_SEM)) /* Drop unused excl arg */ +#ifdef MDB_USE_POSIX_MUTEX /* Drop unused excl arg */ # define mdb_env_close0(env, excl) mdb_env_close1(env) #endif static void mdb_env_close0(MDB_env *env, int excl); @@ -4234,8 +4241,8 @@ mdb_env_excl_lock(MDB_env *env, int *excl) if (!rc) { *excl = 1; } else -# ifdef MDB_USE_POSIX_SEM - if (*excl < 0) /* always true when !MDB_USE_POSIX_SEM */ +# ifndef MDB_USE_POSIX_MUTEX + if (*excl < 0) /* always true when MDB_USE_POSIX_MUTEX */ # endif { lock_info.l_type = F_RDLCK; @@ -4507,7 +4514,7 @@ mdb_env_setup_locks(MDB_env *env, char *lpath, int mode, int *excl) env->me_wmutex = sem_open(env->me_txns->mti_wmname, O_CREAT|O_EXCL, mode, 1); if (env->me_wmutex == SEM_FAILED) goto fail_errno; -#else /* MDB_USE_POSIX_SEM */ +#else /* MDB_USE_POSIX_MUTEX: */ pthread_mutexattr_t mattr; if ((rc = pthread_mutexattr_init(&mattr))