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;
#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)
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;
#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
}
/*
}
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;
- env = bdb->bi_dbenv;
- if ( !env ) return -1;
+ if ( !env || !op || !locker ) 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 ) ) {
}
*locker = lockid;
return 0;
-#endif /* NO_THREADS */
}
#endif
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
{
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;
}
#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