Experimental code that uses one locker ID per thread. Seems to work OK,

is enabled by default. #undef BDB_REUSE_LOCKERS in back-bdb.h to disable.
Probably needs to be disabled when built with NO_THREADS.
This commit is contained in:
Howard Chu 2002-08-24 08:11:08 +00:00
parent 925714ceef
commit d6449b1d57
3 changed files with 74 additions and 4 deletions

View file

@ -156,8 +156,8 @@ struct bdb_op_info {
#define TXN_COMMIT(txn,f) txn_commit((txn), (f))
#define TXN_ABORT(txn) txn_abort((txn))
#define TXN_ID(txn) txn_id(txn)
#define LOCK_ID(env, locker) lock_id(env, locker)
#define LOCK_ID_FREE(env, locker) lock_id_free(env, locker)
#define XLOCK_ID(env, locker) lock_id(env, locker)
#define XLOCK_ID_FREE(env, locker) lock_id_free(env, locker)
#else
#define LOCK_DETECT(env,f,t,a) (env)->lock_detect(env, f, t, a)
#define LOCK_GET(env,i,f,o,m,l) (env)->lock_get(env, i, f, o, m, l)
@ -168,8 +168,18 @@ struct bdb_op_info {
#define TXN_COMMIT(txn,f) (txn)->commit((txn), (f))
#define TXN_ABORT(txn) (txn)->abort((txn))
#define TXN_ID(txn) (txn)->id(txn)
#define LOCK_ID(env, locker) (env)->lock_id(env, locker)
#define LOCK_ID_FREE(env, locker) (env)->lock_id_free(env, locker)
#define XLOCK_ID(env, locker) (env)->lock_id(env, locker)
#define XLOCK_ID_FREE(env, locker) (env)->lock_id_free(env, locker)
#define BDB_REUSE_LOCKERS
#ifdef BDB_REUSE_LOCKERS
#define LOCK_ID_FREE(env, locker)
#define LOCK_ID(env, locker) bdb_locker_id(op, env, locker)
#else
#define LOCK_ID_FREE(env, locker) XLOCK_ID_FREE(env, locker)
#define LOCK_ID(env, locker) XLOCK_ID(env, locker)
#endif
#if DB_VERSION_MINOR > 1 || DB_VERSION_PATCH >= 17
#undef DB_OPEN

View file

@ -1100,3 +1100,57 @@ bdb_lru_print( Cache *cache )
}
}
#endif
#ifdef BDB_REUSE_LOCKERS
void
bdb_locker_id_free( void *key, void *data )
{
DB_ENV *env = key;
int lockid = (int) data;
XLOCK_ID_FREE( env, lockid );
}
int
bdb_locker_id( Operation *op, DB_ENV *env, int *locker )
{
int i, rc, lockid;
void *data;
if ( !env || !op || !locker ) return -1;
/* Shouldn't happen unless we're single-threaded */
if ( !op->o_threadctx ) {
*locker = 0;
return 0;
}
if ( ldap_pvt_thread_pool_getkey( op->o_threadctx, env, &data, NULL ) ) {
for ( i=0, rc=1; rc != 0 && i<4; i++ ) {
rc = XLOCK_ID( env, &lockid );
if (rc) ldap_pvt_thread_yield();
}
if ( rc != 0) {
return rc;
}
data = (void *)lockid;
if ( ( rc = ldap_pvt_thread_pool_setkey( op->o_threadctx, env,
data, bdb_locker_id_free ) ) ) {
XLOCK_ID_FREE( env, lockid );
#ifdef NEW_LOGGING
LDAP_LOG( BACK_BDB, ERR, "bdb_locker_id: err %s(%d)\n",
db_strerror(rc), rc, 0 );
#else
Debug( LDAP_DEBUG_ANY, "bdb_locker_id: err %s(%d)\n",
db_strerror(rc), rc, 0 );
#endif
return rc;
}
} else {
lockid = (int)data;
}
*locker = lockid;
return 0;
}
#endif

View file

@ -343,6 +343,12 @@ int bdb_cache_delete_entry(
);
void bdb_cache_release_all( Cache *cache );
#ifdef BDB_REUSE_LOCKERS
int bdb_locker_id( Operation *op, DB_ENV *env, int *locker );
#endif
#ifdef HAVE_EBCDIC
char *ebcdic_dberror( int rc );