mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-24 00:29:35 -05:00
Simpler fix for NO_THREADS
This commit is contained in:
parent
ff9e580d33
commit
104f8cc409
4 changed files with 14 additions and 32 deletions
|
|
@ -111,9 +111,6 @@ struct bdb_info {
|
|||
u_int32_t bi_txn_cp_kbyte;
|
||||
|
||||
int bi_lock_detect;
|
||||
#ifdef NO_THREADS
|
||||
int bi_locker_id;
|
||||
#endif
|
||||
|
||||
ID bi_lastid;
|
||||
ldap_pvt_thread_mutex_t bi_lastid_mutex;
|
||||
|
|
@ -170,11 +167,8 @@ struct bdb_op_info {
|
|||
#define BDB_REUSE_LOCKERS
|
||||
|
||||
#ifdef BDB_REUSE_LOCKERS
|
||||
/* Hack - we depend on "op" and "bdb" being the right variable names
|
||||
* in each invoker.
|
||||
*/
|
||||
#define LOCK_ID_FREE(env, locker)
|
||||
#define LOCK_ID(env, locker) bdb_locker_id(op, bdb, 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)
|
||||
|
|
|
|||
|
|
@ -136,6 +136,9 @@ int
|
|||
bdb_cache_entry_db_lock
|
||||
( DB_ENV *env, u_int32_t locker, Entry *e, int rw, u_int32_t flags, DB_LOCK *lock )
|
||||
{
|
||||
#ifdef NO_THREADS
|
||||
return 0;
|
||||
#else
|
||||
int rc;
|
||||
DBT lockobj;
|
||||
int db_rw;
|
||||
|
|
@ -161,16 +164,21 @@ bdb_cache_entry_db_lock
|
|||
#endif
|
||||
}
|
||||
return rc;
|
||||
#endif /* NO_THREADS */
|
||||
}
|
||||
|
||||
int
|
||||
bdb_cache_entry_db_unlock
|
||||
( DB_ENV *env, DB_LOCK *lock )
|
||||
{
|
||||
#ifdef NO_THREADS
|
||||
return 0;
|
||||
#else
|
||||
int rc;
|
||||
|
||||
rc = LOCK_PUT ( env, lock );
|
||||
return rc;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -1123,29 +1131,17 @@ bdb_locker_id_free( void *key, void *data )
|
|||
}
|
||||
|
||||
int
|
||||
bdb_locker_id( Operation *op, struct bdb_info *bdb, int *locker )
|
||||
bdb_locker_id( Operation *op, DB_ENV *env, int *locker )
|
||||
{
|
||||
int i, rc, lockid;
|
||||
void *data;
|
||||
DB_ENV *env;
|
||||
|
||||
if ( !bdb || !op || !locker ) return -1;
|
||||
if ( !env || !op || !locker ) return -1;
|
||||
|
||||
env = bdb->bi_dbenv;
|
||||
if ( !env ) return -1;
|
||||
|
||||
#ifdef NO_THREADS
|
||||
if ( !bdb->bi_locker_id ) {
|
||||
rc = XLOCK_ID( env, &bdb->bi_locker_id );
|
||||
if (rc != 0) return rc;
|
||||
}
|
||||
*locker = bdb->bi_locker_id;
|
||||
return 0;
|
||||
#else
|
||||
/* Shouldn't happen */
|
||||
/* Shouldn't happen unless we're single-threaded */
|
||||
if ( !op->o_threadctx ) {
|
||||
*locker = 0;
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( ldap_pvt_thread_pool_getkey( op->o_threadctx, env, &data, NULL ) ) {
|
||||
|
|
@ -1175,6 +1171,5 @@ bdb_locker_id( Operation *op, struct bdb_info *bdb, int *locker )
|
|||
}
|
||||
*locker = lockid;
|
||||
return 0;
|
||||
#endif /* NO_THREADS */
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -178,9 +178,7 @@ bdb_db_open( BackendDB *be )
|
|||
|
||||
bdb->bi_dbenv->set_errpfx( bdb->bi_dbenv, be->be_suffix[0].bv_val );
|
||||
bdb->bi_dbenv->set_errcall( bdb->bi_dbenv, bdb_errcall );
|
||||
#ifndef NO_THREADS
|
||||
bdb->bi_dbenv->set_lk_detect( bdb->bi_dbenv, bdb->bi_lock_detect );
|
||||
#endif
|
||||
|
||||
#ifdef BDB_SUBDIRS
|
||||
{
|
||||
|
|
@ -414,11 +412,6 @@ bdb_db_close( BackendDB *be )
|
|||
|
||||
bdb_cache_release_all (&bdb->bi_cache);
|
||||
|
||||
#if defined(NO_THREADS) && defined(BDB_REUSE_LOCKERS)
|
||||
if ( bdb->bi_locker_id ) {
|
||||
bdb_locker_id_free( bdb->bi_dbenv, bdb->bi_locker_id );
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -366,7 +366,7 @@ void bdb_cache_release_all( Cache *cache );
|
|||
|
||||
#ifdef BDB_REUSE_LOCKERS
|
||||
|
||||
int bdb_locker_id( Operation *op, struct bdb_info *bdb, int *locker );
|
||||
int bdb_locker_id( Operation *op, DB_ENV *env, int *locker );
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue