mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-01-18 11:05:48 +08:00
Rework DB_THREAD support. CDB support needs reimplementation.
This commit is contained in:
parent
69dc4002ac
commit
44146a1cb7
@ -333,12 +333,9 @@ AC_DEFUN([OL_BERKELEY_DB_THREAD],
|
||||
main()
|
||||
{
|
||||
int rc;
|
||||
u_int32_t flags = DB_CREATE | DB_INIT_CDB | DB_INIT_MPOOL |
|
||||
u_int32_t flags = DB_CREATE |
|
||||
#ifdef DB_PRIVATE
|
||||
DB_PRIVATE |
|
||||
#endif
|
||||
#ifdef DB_MPOOL_PRIVATE
|
||||
DB_MPOOL_PRIVATE |
|
||||
#endif
|
||||
DB_THREAD;
|
||||
|
||||
@ -352,17 +349,6 @@ main()
|
||||
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)
|
||||
rc = env->open( env, NULL, flags, 0 );
|
||||
#else
|
||||
@ -415,8 +401,7 @@ if test $ac_cv_header_db_h = yes; then
|
||||
OL_BERKELEY_DB_LINK
|
||||
if test "$ol_cv_lib_db" != no ; then
|
||||
ol_cv_berkeley_db=yes
|
||||
dnl Don't support Concurrent DB API
|
||||
dnl OL_BERKELEY_DB_THREAD
|
||||
OL_BERKELEY_DB_THREAD
|
||||
fi
|
||||
fi
|
||||
])
|
||||
|
@ -733,6 +733,9 @@
|
||||
/* define if you have (or want) 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 */
|
||||
#undef HAVE_BERKELEY_DB
|
||||
|
||||
|
@ -337,6 +337,8 @@ ldap_connect_to_host(LDAP *ld, Sockbuf *sb,
|
||||
|
||||
for( sai=res; sai != NULL; sai=sai->ai_next) {
|
||||
if( sai->ai_addr == NULL ) {
|
||||
osip_debug(ld, "ldap_connect_to_host: getaddrinfo "
|
||||
"ai_addr is NULL?\n", 0, 0, 0);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,6 @@ ldbm_datum_free( LDBM ldbm, Datum data )
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Datum
|
||||
ldbm_datum_dup( LDBM ldbm, Datum data )
|
||||
{
|
||||
@ -60,7 +59,8 @@ ldbm_datum_dup( LDBM ldbm, Datum data )
|
||||
|
||||
static int ldbm_initialized = 0;
|
||||
|
||||
#ifdef HAVE_BERKELEY_DB_THREAD
|
||||
#ifdef USE_BERKELEY_CDB
|
||||
/* not currently supported */
|
||||
#define LDBM_LOCK ((void) 0)
|
||||
#define LDBM_UNLOCK ((void) 0)
|
||||
#else
|
||||
@ -70,7 +70,7 @@ static ldap_pvt_thread_mutex_t ldbm_big_mutex;
|
||||
#endif
|
||||
|
||||
#if !defined( HAVE_BERKELEY_DB ) || (DB_VERSION_MAJOR < 3)
|
||||
/* a dbEnv for BERKELEYv2 */
|
||||
/* a dbEnv for BERKELEYv2 */
|
||||
DB_ENV *ldbm_Env = NULL; /* real or fake, depending on db and version */
|
||||
#endif
|
||||
|
||||
@ -118,25 +118,20 @@ int ldbm_initialize( const char* home )
|
||||
minor < DB_VERSION_MINOR )
|
||||
{
|
||||
#ifdef LDAP_SYSLOG
|
||||
char error[BUFSIZ];
|
||||
|
||||
sprintf( error, "%s (%d)\n", STRERROR( err ), err );
|
||||
|
||||
syslog( LOG_INFO,
|
||||
"ldbm_initialize(): version mismatch\nexpected: %s\ngot: %s\n",
|
||||
DB_VERSION_STRING,
|
||||
version );
|
||||
DB_VERSION_STRING, version );
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
#if DB_VERSION_MAJOR < 3
|
||||
#ifndef HAVE_BERKELEY_DB_THREAD
|
||||
#ifndef USE_BERKELEY_CDB
|
||||
ldap_pvt_thread_mutex_init( &ldbm_big_mutex );
|
||||
#endif
|
||||
|
||||
|
||||
#if DB_VERSION_MAJOR < 3
|
||||
ldbm_Env = calloc( 1, sizeof( DB_ENV ));
|
||||
|
||||
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_errpfx = "==>";
|
||||
|
||||
envFlags = DB_CREATE;
|
||||
envFlags = DB_CREATE | DB_USE_ENVIRON;
|
||||
|
||||
/* add optional flags */
|
||||
#ifdef DB_PRIVATE
|
||||
envFlags |= DB_PRIVATE;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_BERKELEY_DB_THREAD
|
||||
envFlags |= DB_THREAD | DB_INIT_CDB | DB_INIT_MPOOL;
|
||||
#ifdef DB_MPOOL_PRIVATE
|
||||
envFlags |= DB_MPOOL_PRIVATE;
|
||||
#endif
|
||||
envFlags |= DB_THREAD;
|
||||
#endif
|
||||
|
||||
envFlags |= DB_USE_ENVIRON;
|
||||
err = db_appinit( home, NULL, ldbm_Env, envFlags );
|
||||
|
||||
if ( err ) {
|
||||
#ifdef LDAP_SYSLOG
|
||||
char error[BUFSIZ];
|
||||
|
||||
sprintf( error, "%s (%d)\n", STRERROR( err ), err );
|
||||
|
||||
syslog( LOG_INFO,
|
||||
"ldbm_initialize(): FATAL error in db_appinit() : %s\n",
|
||||
error );
|
||||
syslog( LOG_INFO, "ldbm_initialize(): "
|
||||
"FATAL error in db_appinit() : %s (%d)\n",
|
||||
db_strerror( err ), err );
|
||||
#endif
|
||||
return( 1 );
|
||||
}
|
||||
@ -184,12 +170,11 @@ int ldbm_shutdown( void )
|
||||
|
||||
#if DB_VERSION_MAJOR < 3
|
||||
db_appexit( ldbm_Env );
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_BERKELEY_DB_THREAD
|
||||
#ifndef USE_BERKELEY_CDB
|
||||
ldap_pvt_thread_mutex_destroy( &ldbm_big_mutex );
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -224,41 +209,32 @@ DB_ENV *ldbm_initialize_env(const char *home, int dbcachesize, int *envdirok)
|
||||
int err;
|
||||
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 );
|
||||
|
||||
if ( err ) {
|
||||
char error[BUFSIZ];
|
||||
|
||||
sprintf( error, "%s (%d)\n", STRERROR( err ), err );
|
||||
|
||||
#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
|
||||
return( NULL );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
env->set_errcall( env, ldbm_db_errcall );
|
||||
env->set_errpfx( env, "==>" );
|
||||
if (dbcachesize)
|
||||
if (dbcachesize) {
|
||||
env->set_cachesize( env, 0, dbcachesize, 0 );
|
||||
}
|
||||
|
||||
#if 0
|
||||
#if defined( DB_CDB_ALLDB ) && defined( HAVE_BERKELEY_DB_THREAD )
|
||||
env->set_flags( env, DB_CDB_ALLDB, 1 );
|
||||
envFlags = DB_CREATE | DB_INIT_MPOOL | DB_USE_ENVIRON;
|
||||
#ifdef DB_PRIVATE
|
||||
envFlags |= DB_PRIVATE;
|
||||
#endif
|
||||
#ifdef DB_MPOOL_PRIVATE
|
||||
envFlags |= DB_MPOOL_PRIVATE;
|
||||
#endif
|
||||
#ifdef HAVE_BERKELEY_DB_THREAD
|
||||
envFlags |= DB_THREAD;
|
||||
#endif
|
||||
|
||||
#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 );
|
||||
#endif
|
||||
|
||||
if ( err != 0 )
|
||||
{
|
||||
char error[BUFSIZ];
|
||||
|
||||
sprintf( error, "%s (%d)\n", STRERROR( err ), err );
|
||||
|
||||
if ( err != 0 ) {
|
||||
#ifdef LDAP_SYSLOG
|
||||
syslog( LOG_INFO,
|
||||
"ldbm_initialize_env(): FATAL error in dbEnv->open() : %s\n",
|
||||
error );
|
||||
syslog( LOG_INFO, "ldbm_initialize_env(): "
|
||||
"FATAL error in dbEnv->open() : %s (%d)\n",
|
||||
db_strerror( err ), err );
|
||||
#endif
|
||||
env->close( env, 0 );
|
||||
return( NULL );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*envdirok = 1;
|
||||
|
@ -399,6 +399,14 @@ static int slap_get_listener_addresses(
|
||||
|
||||
for ( sai=res; sai; sai=sai->ai_next ) {
|
||||
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);
|
||||
goto errexit;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user