* @{
*/
#ifdef _WIN32
+#define MDB_PIDLOCK 0
#define pthread_t DWORD
#define pthread_mutex_t HANDLE
#define pthread_key_t DWORD
#define Z "z"
+ /** For MDB_LOCK_FORMAT: True if readers take a pid lock in the lockfile */
+#define MDB_PIDLOCK 1
+
#ifdef MDB_USE_POSIX_SEM
#define LOCK_MUTEX_R(env) mdb_sem_wait((env)->me_rmutex)
/** Stamp identifying this as an MDB file. It must be set
* to #MDB_MAGIC. */
uint32_t mtb_magic;
- /** Version number of this lock file. Must be set to #MDB_LOCK_VERSION. */
- uint32_t mtb_version;
+ /** Format of this lock file. Must be set to #MDB_LOCK_FORMAT. */
+ uint32_t mtb_format;
#if defined(_WIN32) || defined(MDB_USE_POSIX_SEM)
char mtb_rmname[MNAME_LEN];
#else
union {
MDB_txbody mtb;
#define mti_magic mt1.mtb.mtb_magic
-#define mti_version mt1.mtb.mtb_version
+#define mti_format mt1.mtb.mtb_format
#define mti_mutex mt1.mtb.mtb_mutex
#define mti_rmname mt1.mtb.mtb_rmname
#define mti_txnid mt1.mtb.mtb_txnid
} mt2;
MDB_reader mti_readers[1];
} MDB_txninfo;
+
+ /** Lockfile format signature: version, features and field layout */
+#define MDB_LOCK_FORMAT \
+ ((uint32_t) \
+ ((MDB_LOCK_VERSION) \
+ /* Flags which describe functionality */ \
+ + (((MDB_PIDLOCK) != 0) << 16)))
/** @} */
/** Common header for all page types.
static void
mdb_txn_reset0(MDB_txn *txn, const char *act);
-#ifdef _WIN32
+#if !(MDB_PIDLOCK) /* Currently the same as defined(_WIN32) */
enum Pidlock_op {
Pidset, Pidcheck
};
static int
mdb_reader_pid(MDB_env *env, enum Pidlock_op op, pid_t pid)
{
-#ifdef _WIN32
+#if !(MDB_PIDLOCK) /* Currently the same as defined(_WIN32) */
int ret = 0;
HANDLE h;
if (op == Pidcheck) {
pthread_mutexattr_destroy(&mattr);
#endif /* _WIN32 || MDB_USE_POSIX_SEM */
- env->me_txns->mti_version = MDB_LOCK_VERSION;
env->me_txns->mti_magic = MDB_MAGIC;
+ env->me_txns->mti_format = MDB_LOCK_FORMAT;
env->me_txns->mti_txnid = 0;
env->me_txns->mti_numreaders = 0;
rc = MDB_INVALID;
goto fail;
}
- if (env->me_txns->mti_version != MDB_LOCK_VERSION) {
- DPRINTF("lock region is version %u, expected version %u",
- env->me_txns->mti_version, MDB_LOCK_VERSION);
+ if (env->me_txns->mti_format != MDB_LOCK_FORMAT) {
+ DPRINTF("lock region has format+version 0x%x, expected 0x%x",
+ env->me_txns->mti_format, MDB_LOCK_FORMAT);
rc = MDB_VERSION_MISMATCH;
goto fail;
}