mirror of
https://git.openldap.org/openldap/openldap.git
synced 2024-12-09 02:52:04 +08:00
Initial CDB implementation.
This commit is contained in:
parent
52067f461e
commit
4b8eae427f
@ -315,20 +315,34 @@ AC_DEFUN([OL_BERKELEY_DB_THREAD],
|
||||
main()
|
||||
{
|
||||
int rc;
|
||||
u_int32_t flags = DB_CREATE | DB_THREAD;
|
||||
u_int32_t flags = DB_CREATE | DB_THREAD | DB_INIT_DB | DB_INIT_MPOOL;
|
||||
|
||||
#if DB_VERSION_MAJOR > 2
|
||||
DB_ENV *env = NULL;
|
||||
|
||||
rc = db_env_create( &env, 0 );
|
||||
|
||||
if( rc == 0 ) {
|
||||
#if (DB_VERSION_MAJOR > 3) || (DB_VERSION_MINOR >= 1)
|
||||
rc = env->open( env, NULL, flags, 0 );
|
||||
#else
|
||||
rc = env->open( env, NULL, NULL, flags, 0 );
|
||||
if( rc ) return rc;
|
||||
|
||||
#ifdef DB_CDB_ALLDB
|
||||
rc = env->set_flags( env, DB_CDB_ALLDB, 1 );
|
||||
if( rc ) goto done;
|
||||
#endif
|
||||
|
||||
#if (DB_VERSION_MAJOR > 3) || (DB_VERSION_MINOR >= 1)
|
||||
rc = env->open( env, NULL, flags, 0 );
|
||||
#else
|
||||
rc = env->open( env, NULL, NULL, flags, 0 );
|
||||
#endif
|
||||
|
||||
#ifdef DB_CDB_ALLDB
|
||||
done:
|
||||
#endif
|
||||
#if (DB_VERSION_MAJOR > 3) || (DB_VERSION_MINOR >= 1)
|
||||
env->remove( env, NULL, DB_FORCE);
|
||||
#else
|
||||
env->remove( env, NULL, NULL, DB_FORCE);
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
DB_ENV env;
|
||||
@ -339,13 +353,6 @@ main()
|
||||
if( rc == 0 ) {
|
||||
db_appexit( &env );
|
||||
}
|
||||
#endif
|
||||
#if DB_VERSION_MAJOR > 2
|
||||
#if (DB_VERSION_MAJOR > 3) || (DB_VERSION_MINOR >= 1)
|
||||
env->remove( env, NULL, DB_FORCE);
|
||||
#else
|
||||
env->remove( env, NULL, NULL, DB_FORCE);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return rc;
|
||||
|
@ -60,9 +60,14 @@ ldbm_datum_dup( LDBM ldbm, Datum data )
|
||||
|
||||
static int ldbm_initialized = 0;
|
||||
|
||||
#ifdef HAVE_BERKELEY_DB_THREAD
|
||||
#define LDBM_LOCK (void) 0;
|
||||
#define LDBM_UNLOCK (void) 0;
|
||||
#else
|
||||
static ldap_pvt_thread_mutex_t ldbm_big_mutex;
|
||||
#define LDBM_LOCK (ldap_pvt_thread_mutex_lock(&ldbm_big_mutex))
|
||||
#define LDBM_UNLOCK (ldap_pvt_thread_mutex_unlock(&ldbm_big_mutex))
|
||||
#endif
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
@ -114,14 +119,18 @@ int ldbm_initialize( const char* home )
|
||||
ldbm_Env = NULL;
|
||||
#endif
|
||||
|
||||
envFlags =
|
||||
envFlags = DB_CREATE;
|
||||
|
||||
/* add optional flags */
|
||||
#ifdef DB_PRIVATE
|
||||
DB_PRIVATE |
|
||||
envFlags |= DB_PRIVATE;
|
||||
#endif
|
||||
#ifdef HAVE_BERKELEY_DB_THREAD
|
||||
DB_THREAD |
|
||||
envFlags |= DB_THREAD;
|
||||
#if DB_VERSION_MAJOR == 2
|
||||
envFlags |= DB_INIT_CDB | DB_INIT_MPOOL;
|
||||
#endif
|
||||
#endif
|
||||
DB_CREATE;
|
||||
|
||||
#if DB_VERSION_MAJOR >= 3
|
||||
err = db_env_create( &ldbm_Env, 0 );
|
||||
@ -151,7 +160,10 @@ int ldbm_initialize( const char* home )
|
||||
ldbm_Env->set_errcall( ldbm_Env, ldbm_db_errcall );
|
||||
ldbm_Env->set_errpfx( ldbm_Env, "==>" );
|
||||
|
||||
envFlags |= DB_INIT_MPOOL | DB_USE_ENVIRON;
|
||||
#ifdef HAVE_BERKELEY_DB_THREAD
|
||||
envFlags |= DB_INIT_CDB | DB_INIT_MPOOL;
|
||||
#endif
|
||||
envFlags |= DB_USE_ENVIRON;
|
||||
|
||||
#if (DB_VERSION_MAJOR > 3) || (DB_VERSION_MINOR >= 1)
|
||||
err = ldbm_Env->open( ldbm_Env, home, envFlags, 0 );
|
||||
|
Loading…
Reference in New Issue
Block a user