Add in Ksp's LDBM appinit changes.

This commit is contained in:
Kurt Zeilenga 1999-01-23 22:44:26 +00:00
parent d9cebead9f
commit 283a9b9b0e
3 changed files with 75 additions and 8 deletions

13
CHANGES
View File

@ -2,12 +2,13 @@ OpenLDAP Change Log
Changes included in OpenLDAP 1.2
CVS Tag: OPENLDAP_REL_ENG_1_2
Add ldappasswd() tool
Add salted MD5/SHA1 password support
Add client/tools password prompting (-W)
Add slapd alternative args/pid file locations
Add slapd logging option
Add slapd nextid chunking
Added ldappasswd() tool
Added salted MD5/SHA1 password support
Added client/tools password prompting (-W)
Added slapd alternative args/pid file locations
Added slapd logging option
Added slapd nextid chunking
Added LDBM DB2 debugging support
Fixed client SIGPIPE handling
Fixed configure wait3 handling
Fixed lber leaking ber_scanf

View File

@ -2,12 +2,15 @@
/* Patched for Berkeley DB version 2.0; /KSp; 98/02/23
*
* - basic implementation; 1998/02/23, /KSp
* - DB version 2.6.4b ; 1998/12/28, /KSp
* - DB_DBT_MALLOC ; 1998/03/22, /KSp
* - basic implementation; 1998/02/23, /KSp
*/
#include "portable.h"
#include "syslog.h"
#ifdef SLAPD_LDBM
#include <stdio.h>
@ -38,6 +41,21 @@ ldbm_malloc( size_t size )
return( calloc( 1, size ));
}
/* a dbEnv for BERKELEYv2 */
#include "lthread.h"
DB_ENV dbEnv;
int dbEnvInit = 0;
pthread_mutex_t dbEnvInit_mutex;
void
ldbm_db_errcall( const char *prefix, char *message )
{
syslog( LOG_INFO, "ldbm_db_errcall(): %s %s", prefix, message );
}
#endif
@ -49,12 +67,57 @@ ldbm_open( char *name, int rw, int mode, int dbcachesize )
#ifdef HAVE_BERKELEY_DB2
DB_INFO dbinfo;
/* initialize an environment for the DB application */
pthread_mutex_lock( &dbEnvInit_mutex );
if ( !dbEnvInit ) {
char *dir;
char tmp[BUFSIZ];
int err = 0;
int envFlags = DB_CREATE | DB_THREAD;
strcpy( tmp, name );
if ( ( dir = strrchr( tmp, '/' )) ) {
*dir ='\0';
dir = tmp;
} else {
dir = "/";
}
memset( &dbEnv, 0, sizeof( dbEnv ));
dbEnv.db_errcall = ldbm_db_errcall;
dbEnv.db_errpfx = "==>";
if ( ( err = db_appinit( NULL, NULL, &dbEnv, envFlags )) ) {
char error[BUFSIZ];
if ( err < 0 ) sprintf( error, "%ld\n", (long) err );
else sprintf( error, "%s\n", strerror( err ));
syslog( LOG_INFO,
"ldbm_open(): FATAL error in db_appinit(%s) : %s\n",
dir, error );
exit( 1 );
}
dbEnvInit = 1;
}
pthread_mutex_unlock( &dbEnvInit_mutex );
memset( &dbinfo, 0, sizeof( dbinfo ));
dbinfo.db_cachesize = dbcachesize;
dbinfo.db_pagesize = DEFAULT_DB_PAGE_SIZE;
dbinfo.db_malloc = ldbm_malloc;
(void) db_open( name, DB_TYPE, rw, mode, NULL, &dbinfo, &ret );
(void) db_open( name, DB_TYPE, rw, mode, &dbEnv, &dbinfo, &ret );
#else
void *info;

View File

@ -19,6 +19,8 @@ ldbm_back_init(
char *argv[ 4 ];
int i;
extern pthread_mutex_t dbEnvInit_mutex;
/* allocate backend-specific stuff */
li = (struct ldbminfo *) ch_calloc( 1, sizeof(struct ldbminfo) );
@ -79,6 +81,7 @@ ldbm_back_init(
pthread_cond_init( &li->li_dbcache[i].dbc_cv,
pthread_condattr_default );
}
pthread_mutex_init( &dbEnvInit_mutex, pthread_mutexattr_default );
be->be_private = li;
}