#endif
#ifdef MDB_VL32
MDB_ID3L me_rpages; /**< like #mt_rpages, but global to env */
- mdb_mutex_t me_rpmutex; /**< control access to #me_rpages */
+ pthread_mutex_t me_rpmutex; /**< control access to #me_rpages */
#define MDB_ERPAGE_SIZE 16384
#define MDB_ERPAGE_MAX (MDB_ERPAGE_SIZE-1)
unsigned int me_rpcheck;
if (!txn->mt_parent) {
MDB_ID3L el = env->me_rpages, tl = txn->mt_rpages;
unsigned i, x, n = tl[0].mid;
- LOCK_MUTEX0(env->me_rpmutex);
+ pthread_mutex_lock(&env->me_rpmutex);
for (i = 1; i <= n; i++) {
if (tl[i].mid & (MDB_RPAGE_CHUNK-1)) {
/* tmp overflow pages that we didn't share in env */
}
}
}
- UNLOCK_MUTEX(env->me_rpmutex);
+ pthread_mutex_unlock(&env->me_rpmutex);
tl[0].mid = 0;
if (mode & MDB_END_FREE)
free(tl);
#ifdef _WIN32
env->me_rpmutex = CreateMutex(NULL, FALSE, NULL);
#else
- pthread_mutex_init(env->me_rpmutex, NULL);
+ pthread_mutex_init(&env->me_rpmutex, NULL);
#endif
#endif
#ifdef _WIN32
if (env->me_rpmutex) CloseHandle(env->me_rpmutex);
#else
- pthread_mutex_destroy(env->me_rpmutex);
+ pthread_mutex_destroy(&env->me_rpmutex);
#endif
#endif
/* if no active ref, see if we can replace in env */
if (!tl[x].mref) {
unsigned i;
- LOCK_MUTEX0(env->me_rpmutex);
+ pthread_mutex_lock(&env->me_rpmutex);
i = mdb_mid3l_search(el, tl[x].mid);
if (el[i].mref == 1) {
/* just us, replace it */
/* there are others, remove ourself */
el[i].mref--;
}
- UNLOCK_MUTEX(env->me_rpmutex);
+ pthread_mutex_unlock(&env->me_rpmutex);
}
}
}
if (tl[0].mid >= MDB_TRPAGE_MAX - txn->mt_rpcheck) {
unsigned i, y;
/* purge unref'd pages from our list and unref in env */
- LOCK_MUTEX0(env->me_rpmutex);
+ pthread_mutex_lock(&env->me_rpmutex);
retry:
y = 0;
for (i=1; i<tl[0].mid; i++) {
el[x].mref--;
}
}
- UNLOCK_MUTEX(env->me_rpmutex);
+ pthread_mutex_unlock(&env->me_rpmutex);
if (!y) {
/* we didn't find any unref'd chunks.
* if we're out of room, fail.
id3.mid = pgno;
/* search for page in env */
- LOCK_MUTEX0(env->me_rpmutex);
+ pthread_mutex_lock(&env->me_rpmutex);
x = mdb_mid3l_search(el, pgno);
if (x <= el[0].mid && el[x].mid == pgno) {
id3.mptr = el[x].mptr;
el[x].mcnt = id3.mcnt;
} else {
id3.mid = pg0;
- UNLOCK_MUTEX(env->me_rpmutex);
+ pthread_mutex_unlock(&env->me_rpmutex);
goto found;
}
}
el[x].mref++;
- UNLOCK_MUTEX(env->me_rpmutex);
+ pthread_mutex_unlock(&env->me_rpmutex);
goto found;
}
if (el[0].mid >= MDB_ERPAGE_MAX - env->me_rpcheck) {
goto retry;
}
if (el[0].mid >= MDB_ERPAGE_MAX) {
- UNLOCK_MUTEX(env->me_rpmutex);
+ pthread_mutex_unlock(&env->me_rpmutex);
return MDB_MAP_FULL;
}
env->me_rpcheck /= 2;
MAP(rc, env, id3.mptr, len, off);
if (rc) {
fail:
- UNLOCK_MUTEX(env->me_rpmutex);
+ pthread_mutex_unlock(&env->me_rpmutex);
return rc;
}
/* If this page is far enough from the end of the env, scan for
}
}
mdb_mid3l_insert(el, &id3);
- UNLOCK_MUTEX(env->me_rpmutex);
+ pthread_mutex_unlock(&env->me_rpmutex);
found:
mdb_mid3l_insert(tl, &id3);
} else {