From: Hallvard Furuseth Date: Sun, 12 Mar 2017 19:08:53 +0000 (+0100) Subject: ITS#8582 Fill in MDB_LOCK_FORMAT X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=b5e5fcc31dd6719a618cd825a0a9c4ecef5d045b;p=openldap ITS#8582 Fill in MDB_LOCK_FORMAT Attempt to stop liblmdb variants compiled with conflicting options from using the lockfile at the same time and thus breaking it. --- diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index 59e3d938b1..4a364f7fdb 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -480,12 +480,6 @@ typedef pthread_mutex_t *mdb_mutexref_t; #define MUTEXNAME_PREFIX "/MDB" #endif -#ifdef MDB_USE_SYSV_SEM -#define SYSV_SEM_FLAG 1 /**< SysV sems in lockfile format */ -#else -#define SYSV_SEM_FLAG 0 -#endif - /** @} */ #ifdef MDB_ROBUST_SUPPORTED @@ -628,6 +622,10 @@ static txnid_t mdb_debug_start; #define MDB_DATA_VERSION ((MDB_DEVEL) ? 999 : 1) /** The version number for a database's lockfile format. */ #define MDB_LOCK_VERSION ((MDB_DEVEL) ? 999 : 2) + /** Number of bits representing #MDB_LOCK_VERSION in #MDB_LOCK_FORMAT. + * The remaining bits must leave room for #MDB_lock_desc. + */ +#define MDB_LOCK_VERSION_BITS 12 /** @brief The max size of a key we can write, or 0 for computed max. * @@ -693,6 +691,19 @@ static txnid_t mdb_debug_start; /** Round \b n up to an even number. */ #define EVEN(n) (((n) + 1U) & -2) /* sign-extending -2 to match n+1U */ + /** Least significant 1-bit of \b n. n must be of an unsigned type. */ +#define LOW_BIT(n) ((n) & (-(n))) + + /** (log2(\b p2) % \b n), for p2 = power of 2 and 0 < n < 8. */ +#define LOG2_MOD(p2, n) (7 - 86 / ((p2) % ((1U<<(n))-1) + 11)) + /* Explanation: Let p2 = 2**(n*y + x), x> (CACHELINE>64), 5)) + + 6 * (sizeof(MDB_PID_T)/4 % 3) /* legacy(2) to word(4/8)? */ + + 18 * (sizeof(pthread_t)/4 % 5) /* can be struct{id, active data} */ + + 90 * (sizeof(MDB_txbody) / CACHELINE % 3) + + 270 * (MDB_LOCK_TYPE % 120) + /* The above is < 270*120 < 2**15 */ + + ((sizeof(txnid_t) == 8) << 15) /* 32bit/64bit */ + + ((sizeof(MDB_reader) > CACHELINE) << 16) + /* Not really needed - implied by MDB_LOCK_TYPE != (_WIN32 locking) */ + + (((MDB_PIDLOCK) != 0) << 17) + /* 18 bits total: Must be <= (32 - MDB_LOCK_VERSION_BITS). */ +}; /** @} */ /** Common header for all page types. The page type depends on #mp_flags.