mdb_txn_renew0(): Fix un-mutexed me_flags update.

Replace env flag MDB_LIVE_READER with field me_live_reader.
incre
Hallvard Furuseth 11 years ago
parent 684bb867ce
commit a22c31115f
  1. 3
      libraries/liblmdb/lmdb.h
  2. 7
      libraries/liblmdb/mdb.c

@ -668,7 +668,8 @@ void mdb_env_close(MDB_env *env);
/** @brief Set environment flags. /** @brief Set environment flags.
* *
* This may be used to set some flags in addition to those from * This may be used to set some flags in addition to those from
* #mdb_env_open(), or to unset these flags. * #mdb_env_open(), or to unset these flags. If several threads
* change the flags at the same time, the result is undefined.
* @param[in] env An environment handle returned by #mdb_env_create() * @param[in] env An environment handle returned by #mdb_env_create()
* @param[in] flags The flags to change, bitwise OR'ed together * @param[in] flags The flags to change, bitwise OR'ed together
* @param[in] onoff A non-zero value sets the flags, zero clears them. * @param[in] onoff A non-zero value sets the flags, zero clears them.

@ -1034,8 +1034,6 @@ struct MDB_env {
#define MDB_ENV_ACTIVE 0x20000000U #define MDB_ENV_ACTIVE 0x20000000U
/** me_txkey is set */ /** me_txkey is set */
#define MDB_ENV_TXKEY 0x10000000U #define MDB_ENV_TXKEY 0x10000000U
/** Have liveness lock in reader table */
#define MDB_LIVE_READER 0x08000000U
uint32_t me_flags; /**< @ref mdb_env */ uint32_t me_flags; /**< @ref mdb_env */
unsigned int me_psize; /**< DB page size, inited from me_os_psize */ unsigned int me_psize; /**< DB page size, inited from me_os_psize */
unsigned int me_os_psize; /**< OS page size, from #GET_PAGESIZE */ unsigned int me_os_psize; /**< OS page size, from #GET_PAGESIZE */
@ -1071,6 +1069,7 @@ struct MDB_env {
#if !(MDB_MAXKEYSIZE) #if !(MDB_MAXKEYSIZE)
unsigned int me_maxkey; /**< max size of a key */ unsigned int me_maxkey; /**< max size of a key */
#endif #endif
int me_live_reader; /**< have liveness lock in reader table */
#ifdef _WIN32 #ifdef _WIN32
int me_pidquery; /**< Used in OpenProcess */ int me_pidquery; /**< Used in OpenProcess */
HANDLE me_rmutex; /* Windows mutexes don't reside in shared mem */ HANDLE me_rmutex; /* Windows mutexes don't reside in shared mem */
@ -2268,11 +2267,11 @@ mdb_txn_renew0(MDB_txn *txn)
MDB_PID_T pid = env->me_pid; MDB_PID_T pid = env->me_pid;
pthread_t tid = pthread_self(); pthread_t tid = pthread_self();
if (!(env->me_flags & MDB_LIVE_READER)) { if (!env->me_live_reader) {
rc = mdb_reader_pid(env, Pidset, pid); rc = mdb_reader_pid(env, Pidset, pid);
if (rc) if (rc)
return rc; return rc;
env->me_flags |= MDB_LIVE_READER; env->me_live_reader = 1;
} }
LOCK_MUTEX_R(env); LOCK_MUTEX_R(env);

Loading…
Cancel
Save