DB3 fixes

This commit is contained in:
Kurt Zeilenga 2000-05-26 05:47:02 +00:00
parent b5fab0c88e
commit e0fc97bfa7
2 changed files with 25 additions and 15 deletions

View File

@ -58,7 +58,7 @@ ldbm_datum_dup( LDBM ldbm, Datum data )
static int ldbm_initialized = 0; static int ldbm_initialized = 0;
#if defined( HAVE_BERKELEY_DB_THREAD ) || defined( HAVE_BERKELEY_DB_THREAD ) #ifdef HAVE_BERKELEY_DB_THREAD
#define LDBM_LOCK ((void)0) #define LDBM_LOCK ((void)0)
#define LDBM_UNLOCK ((void)0) #define LDBM_UNLOCK ((void)0)
#else #else
@ -100,7 +100,6 @@ ldbm_db_errcall( const char *prefix, char *message )
} }
/* a dbEnv for BERKELEYv2 */ /* a dbEnv for BERKELEYv2 */
static DB_ENV ldbm_Env_internal;
DB_ENV *ldbm_Env = NULL; DB_ENV *ldbm_Env = NULL;
int ldbm_initialize( void ) int ldbm_initialize( void )
@ -110,26 +109,30 @@ int ldbm_initialize( void )
if(ldbm_initialized++) return 1; if(ldbm_initialized++) return 1;
memset( &ldbm_Env_internal, 0, sizeof( DB_ENV )); #if DB_VERSION_MAJOR < 3
ldbm_Env = &ldbm_Env_internal; ldbm_Env = calloc( 1, sizeof( DB_ENV ));
if( ldbm_Env == NULL ) return 1;
ldbm_Env->db_errcall = ldbm_db_errcall; ldbm_Env->db_errcall = ldbm_db_errcall;
ldbm_Env->db_errpfx = "==>"; ldbm_Env->db_errpfx = "==>";
#else
ldbm_Env = NULL;
#endif
envFlags = DB_CREATE envFlags =
#if defined( HAVE_BERKELEY_DB_THREAD ) #if defined( HAVE_BERKELEY_DB_THREAD )
| DB_THREAD DB_THREAD |
#endif #endif
; DB_CREATE;
if (
#if DB_VERSION_MAJOR >= 3 #if DB_VERSION_MAJOR >= 3
( err = db_env_create( &ldbm_Env, 0)) err = db_env_create( &ldbm_Env, 0 );
#elif DB_VERSION_MAJOR >= 2 #elif DB_VERSION_MAJOR >= 2
( err = db_appinit( NULL, NULL, ldbm_Env, envFlags )) err = db_appinit( NULL, NULL, ldbm_Env, envFlags );
#endif #endif
)
{ if ( err ) {
char error[BUFSIZ]; char error[BUFSIZ];
if ( err < 0 ) { if ( err < 0 ) {
@ -144,7 +147,11 @@ int ldbm_initialize( void )
#endif #endif
return( 1 ); return( 1 );
} }
#if DB_VERSION_MAJOR >= 3 #if DB_VERSION_MAJOR >= 3
ldbm_Env->set_errcall( ldbm_Env, ldbm_db_errcall );
ldbm_Env->set_errpfx( ldbm_Env, "==>" );
envFlags |= DB_INIT_MPOOL; envFlags |= DB_INIT_MPOOL;
err = ldbm_Env->open( ldbm_Env, NULL, NULL, envFlags, 0 ); err = ldbm_Env->open( ldbm_Env, NULL, NULL, envFlags, 0 );
if ( err != 0 ) if ( err != 0 )
@ -161,6 +168,7 @@ int ldbm_initialize( void )
"ldbm_initialize(): FATAL error in db_appinit() : %s\n", "ldbm_initialize(): FATAL error in db_appinit() : %s\n",
error ); error );
#endif #endif
ldbm_Env->close( ldbm_Env, 0 );
return( 1 ); return( 1 );
} }
#endif #endif

View File

@ -14,7 +14,7 @@ LDAP_BEGIN_DECL
#define DEFAULT_CACHE_SIZE 1000 #define DEFAULT_CACHE_SIZE 1000
#ifdef HAVE_BERKELEY_DB2 #if defined(HAVE_BERKELEY_DB) && DB_VERSION_MAJOR >= 2
# define DEFAULT_DBCACHE_SIZE (100 * DEFAULT_DB_PAGE_SIZE) # define DEFAULT_DBCACHE_SIZE (100 * DEFAULT_DB_PAGE_SIZE)
#else #else
# define DEFAULT_DBCACHE_SIZE 100000 # define DEFAULT_DBCACHE_SIZE 100000
@ -122,8 +122,10 @@ struct ldbminfo {
DBCache li_dbcache[MAXDBCACHE]; DBCache li_dbcache[MAXDBCACHE];
ldap_pvt_thread_mutex_t li_dbcache_mutex; ldap_pvt_thread_mutex_t li_dbcache_mutex;
ldap_pvt_thread_cond_t li_dbcache_cv; ldap_pvt_thread_cond_t li_dbcache_cv;
#ifdef HAVE_BERKELEY_DB2 #if 0
DB_ENV li_db_env; #if defined(HAVE_BERKELEY_DB) && DB_VERSION_MAJOR >= 2
DB_ENV *li_db_env;
#endif
#endif #endif
}; };