]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
Add in Ksp's LDBM appinit changes.
authorKurt Zeilenga <kurt@openldap.org>
Sat, 23 Jan 1999 22:44:26 +0000 (22:44 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Sat, 23 Jan 1999 22:44:26 +0000 (22:44 +0000)
CHANGES
libraries/libldbm/ldbm.c
servers/slapd/back-ldbm/init.c

diff --git a/CHANGES b/CHANGES
index 1f74b1185edda45bfa357ca1ec94cd16038ce8dc..0a0d7ef91ef0f14e21ba32fac3a4cfb73a2e21b9 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -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
index 72a212f8ca044c5b610197647da59b1382218437..ca3f15d258437d6548776998aacd84e628e60918 100644 (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;
index 21a7dc5136d74c5d5f044cca336f2e6c909fdd59..cd5556e87185bec2217a25a270b176dccd229ad6 100644 (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;
 }