Rework DB_THREAD support. CDB support needs reimplementation.

This commit is contained in:
Kurt Zeilenga 2001-10-01 06:08:46 +00:00
parent 69dc4002ac
commit 44146a1cb7
6 changed files with 366 additions and 295 deletions

View File

@ -333,12 +333,9 @@ AC_DEFUN([OL_BERKELEY_DB_THREAD],
main() main()
{ {
int rc; int rc;
u_int32_t flags = DB_CREATE | DB_INIT_CDB | DB_INIT_MPOOL | u_int32_t flags = DB_CREATE |
#ifdef DB_PRIVATE #ifdef DB_PRIVATE
DB_PRIVATE | DB_PRIVATE |
#endif
#ifdef DB_MPOOL_PRIVATE
DB_MPOOL_PRIVATE |
#endif #endif
DB_THREAD; DB_THREAD;
@ -352,17 +349,6 @@ main()
return rc; return rc;
} }
#if 0
#ifdef DB_CDB_ALLDB
rc = env->set_flags( env, DB_CDB_ALLDB, 1 );
if( rc ) {
printf("BerkeleyDB: %s\n", db_strerror(rc) );
return rc;
}
#endif
#endif
#if (DB_VERSION_MAJOR > 3) || (DB_VERSION_MINOR >= 1) #if (DB_VERSION_MAJOR > 3) || (DB_VERSION_MINOR >= 1)
rc = env->open( env, NULL, flags, 0 ); rc = env->open( env, NULL, flags, 0 );
#else #else
@ -415,8 +401,7 @@ if test $ac_cv_header_db_h = yes; then
OL_BERKELEY_DB_LINK OL_BERKELEY_DB_LINK
if test "$ol_cv_lib_db" != no ; then if test "$ol_cv_lib_db" != no ; then
ol_cv_berkeley_db=yes ol_cv_berkeley_db=yes
dnl Don't support Concurrent DB API OL_BERKELEY_DB_THREAD
dnl OL_BERKELEY_DB_THREAD
fi fi
fi fi
]) ])

534
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -733,6 +733,9 @@
/* define if you have (or want) no threads */ /* define if you have (or want) no threads */
#undef NO_THREADS #undef NO_THREADS
/* define if Berkeley DB has DB_THREAD support */
#undef HAVE_BERKELEY_DB_THREAD
/* define this if Berkeley DB is available */ /* define this if Berkeley DB is available */
#undef HAVE_BERKELEY_DB #undef HAVE_BERKELEY_DB

View File

@ -337,6 +337,8 @@ ldap_connect_to_host(LDAP *ld, Sockbuf *sb,
for( sai=res; sai != NULL; sai=sai->ai_next) { for( sai=res; sai != NULL; sai=sai->ai_next) {
if( sai->ai_addr == NULL ) { if( sai->ai_addr == NULL ) {
osip_debug(ld, "ldap_connect_to_host: getaddrinfo "
"ai_addr is NULL?\n", 0, 0, 0);
continue; continue;
} }

View File

@ -35,7 +35,6 @@ ldbm_datum_free( LDBM ldbm, Datum data )
} }
} }
Datum Datum
ldbm_datum_dup( LDBM ldbm, Datum data ) ldbm_datum_dup( LDBM ldbm, Datum data )
{ {
@ -60,7 +59,8 @@ ldbm_datum_dup( LDBM ldbm, Datum data )
static int ldbm_initialized = 0; static int ldbm_initialized = 0;
#ifdef HAVE_BERKELEY_DB_THREAD #ifdef USE_BERKELEY_CDB
/* not currently supported */
#define LDBM_LOCK ((void) 0) #define LDBM_LOCK ((void) 0)
#define LDBM_UNLOCK ((void) 0) #define LDBM_UNLOCK ((void) 0)
#else #else
@ -118,25 +118,20 @@ int ldbm_initialize( const char* home )
minor < DB_VERSION_MINOR ) minor < DB_VERSION_MINOR )
{ {
#ifdef LDAP_SYSLOG #ifdef LDAP_SYSLOG
char error[BUFSIZ];
sprintf( error, "%s (%d)\n", STRERROR( err ), err );
syslog( LOG_INFO, syslog( LOG_INFO,
"ldbm_initialize(): version mismatch\nexpected: %s\ngot: %s\n", "ldbm_initialize(): version mismatch\nexpected: %s\ngot: %s\n",
DB_VERSION_STRING, DB_VERSION_STRING, version );
version );
#endif #endif
return 1; return 1;
} }
} }
#if DB_VERSION_MAJOR < 3 #ifndef USE_BERKELEY_CDB
#ifndef HAVE_BERKELEY_DB_THREAD
ldap_pvt_thread_mutex_init( &ldbm_big_mutex ); ldap_pvt_thread_mutex_init( &ldbm_big_mutex );
#endif #endif
#if DB_VERSION_MAJOR < 3
ldbm_Env = calloc( 1, sizeof( DB_ENV )); ldbm_Env = calloc( 1, sizeof( DB_ENV ));
if( ldbm_Env == NULL ) return 1; if( ldbm_Env == NULL ) return 1;
@ -144,32 +139,23 @@ int ldbm_initialize( const char* home )
ldbm_Env->db_errcall = ldbm_db_errcall; ldbm_Env->db_errcall = ldbm_db_errcall;
ldbm_Env->db_errpfx = "==>"; ldbm_Env->db_errpfx = "==>";
envFlags = DB_CREATE; envFlags = DB_CREATE | DB_USE_ENVIRON;
/* add optional flags */ /* add optional flags */
#ifdef DB_PRIVATE #ifdef DB_PRIVATE
envFlags |= DB_PRIVATE; envFlags |= DB_PRIVATE;
#endif #endif
#ifdef HAVE_BERKELEY_DB_THREAD #ifdef HAVE_BERKELEY_DB_THREAD
envFlags |= DB_THREAD | DB_INIT_CDB | DB_INIT_MPOOL; envFlags |= DB_THREAD;
#ifdef DB_MPOOL_PRIVATE
envFlags |= DB_MPOOL_PRIVATE;
#endif
#endif #endif
envFlags |= DB_USE_ENVIRON;
err = db_appinit( home, NULL, ldbm_Env, envFlags ); err = db_appinit( home, NULL, ldbm_Env, envFlags );
if ( err ) { if ( err ) {
#ifdef LDAP_SYSLOG #ifdef LDAP_SYSLOG
char error[BUFSIZ]; syslog( LOG_INFO, "ldbm_initialize(): "
"FATAL error in db_appinit() : %s (%d)\n",
sprintf( error, "%s (%d)\n", STRERROR( err ), err ); db_strerror( err ), err );
syslog( LOG_INFO,
"ldbm_initialize(): FATAL error in db_appinit() : %s\n",
error );
#endif #endif
return( 1 ); return( 1 );
} }
@ -184,12 +170,11 @@ int ldbm_shutdown( void )
#if DB_VERSION_MAJOR < 3 #if DB_VERSION_MAJOR < 3
db_appexit( ldbm_Env ); db_appexit( ldbm_Env );
#endif
#ifndef HAVE_BERKELEY_DB_THREAD #ifndef USE_BERKELEY_CDB
ldap_pvt_thread_mutex_destroy( &ldbm_big_mutex ); ldap_pvt_thread_mutex_destroy( &ldbm_big_mutex );
#endif #endif
#endif
return 0; return 0;
} }
@ -224,41 +209,32 @@ DB_ENV *ldbm_initialize_env(const char *home, int dbcachesize, int *envdirok)
int err; int err;
u_int32_t envFlags; u_int32_t envFlags;
envFlags = DB_CREATE |
#if defined( DB_PRIVATE ) /* comment out DB_PRIVATE setting to use */
DB_PRIVATE | /* db_stat to view cache behavior */
#endif
DB_USE_ENVIRON;
#ifdef HAVE_BERKELEY_DB_THREAD
envFlags |= DB_THREAD | DB_INIT_CDB | DB_INIT_MPOOL;
#ifdef DB_MPOOL_PRIVATE
envFlags |= DB_MPOOL_PRIVATE;
#endif
#endif
err = db_env_create( &env, 0 ); err = db_env_create( &env, 0 );
if ( err ) { if ( err ) {
char error[BUFSIZ];
sprintf( error, "%s (%d)\n", STRERROR( err ), err );
#ifdef LDAP_SYSLOG #ifdef LDAP_SYSLOG
syslog( LOG_INFO, "ldbm_initialize_env(): FATAL error in db_env_create() : %s\n", error ); syslog( LOG_INFO, "ldbm_initialize_env(): "
"FATAL error in db_env_create() : %s (%d)\n",
db_strerror( err ), err );
#endif #endif
return( NULL ); return NULL;
} }
env->set_errcall( env, ldbm_db_errcall ); env->set_errcall( env, ldbm_db_errcall );
env->set_errpfx( env, "==>" ); env->set_errpfx( env, "==>" );
if (dbcachesize) if (dbcachesize) {
env->set_cachesize( env, 0, dbcachesize, 0 ); env->set_cachesize( env, 0, dbcachesize, 0 );
}
#if 0 envFlags = DB_CREATE | DB_INIT_MPOOL | DB_USE_ENVIRON;
#if defined( DB_CDB_ALLDB ) && defined( HAVE_BERKELEY_DB_THREAD ) #ifdef DB_PRIVATE
env->set_flags( env, DB_CDB_ALLDB, 1 ); envFlags |= DB_PRIVATE;
#endif #endif
#ifdef DB_MPOOL_PRIVATE
envFlags |= DB_MPOOL_PRIVATE;
#endif
#ifdef HAVE_BERKELEY_DB_THREAD
envFlags |= DB_THREAD;
#endif #endif
#if DB_VERSION_MAJOR > 3 || DB_VERSION_MINOR > 0 #if DB_VERSION_MAJOR > 3 || DB_VERSION_MINOR > 0
@ -268,19 +244,14 @@ DB_ENV *ldbm_initialize_env(const char *home, int dbcachesize, int *envdirok)
err = env->open( env, home, NULL, envFlags, 0 ); err = env->open( env, home, NULL, envFlags, 0 );
#endif #endif
if ( err != 0 ) if ( err != 0 ) {
{
char error[BUFSIZ];
sprintf( error, "%s (%d)\n", STRERROR( err ), err );
#ifdef LDAP_SYSLOG #ifdef LDAP_SYSLOG
syslog( LOG_INFO, syslog( LOG_INFO, "ldbm_initialize_env(): "
"ldbm_initialize_env(): FATAL error in dbEnv->open() : %s\n", "FATAL error in dbEnv->open() : %s (%d)\n",
error ); db_strerror( err ), err );
#endif #endif
env->close( env, 0 ); env->close( env, 0 );
return( NULL ); return NULL;
} }
*envdirok = 1; *envdirok = 1;

View File

@ -399,6 +399,14 @@ static int slap_get_listener_addresses(
for ( sai=res; sai; sai=sai->ai_next ) { for ( sai=res; sai; sai=sai->ai_next ) {
if( sai->ai_addr == NULL ) { if( sai->ai_addr == NULL ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "connection", LDAP_LEVEL_INFO,
"slap_get_listener_addresses: "
"getaddrinfo ai_addr is NULL?\n" ));
#else
Debug( LDAP_DEBUG_ANY, "slap_get_listener_addresses: "
"getaddrinfo ai_addr is NULL?\n", 0, 0, 0 );
#endif
freeaddrinfo(res); freeaddrinfo(res);
goto errexit; goto errexit;
} }