]> git.sur5r.net Git - openldap/commitdiff
Sync with HEAD
authorKurt Zeilenga <kurt@openldap.org>
Thu, 3 Nov 2005 21:24:54 +0000 (21:24 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Thu, 3 Nov 2005 21:24:54 +0000 (21:24 +0000)
libraries/libldap/init.c
servers/slapd/backend.c
servers/slapd/bconfig.c
servers/slapd/overlays/pcache.c
servers/slapd/proto-slap.h

index cb0fc14e9a0db0a433282efd3deb62a3b33ad363..32d54e2977347cb8bad14f70e55e77b9c55bc4ff 100644 (file)
@@ -410,10 +410,13 @@ ldap_int_destroy_global_options(void)
        WSACleanup( );
 #endif
 
+#if defined(LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND) \
+       || defined(HAVE_TLS) || defined(HAVE_CYRUS_SASL)
        if ( ldap_int_hostname ) {
                LDAP_FREE( ldap_int_hostname );
                ldap_int_hostname = NULL;
        }
+#endif
 }
 
 /* 
index 77dcf4a422b7eb562738fb6e564b50a26b8820da..97cd302a342428c7a6a8f51d2e40b81f7771b372 100644 (file)
@@ -503,9 +503,9 @@ BackendInfo* backend_info(const char *type)
 
 BackendDB *
 backend_db_init(
-    const char *type )
+    const char *type,
+       BackendDB *be )
 {
-       Backend *be;
        BackendInfo *bi = backend_info(type);
        int     rc = 0;
 
@@ -514,9 +514,14 @@ backend_db_init(
                return NULL;
        }
 
-       be = ch_calloc( 1, sizeof(Backend) );
-       nbackends++;
-       LDAP_STAILQ_INSERT_TAIL(&backendDB, be, be_next);
+       /* If be is provided, treat it as private. Otherwise allocate
+        * one and add it to the global list.
+        */
+       if ( !be ) {
+               be = ch_calloc( 1, sizeof(Backend) );
+               nbackends++;
+               LDAP_STAILQ_INSERT_TAIL(&backendDB, be, be_next);
+       }
 
        be->bd_info = bi;
 
index 634e3ff96219834dcf2c980dbbb6e619e7c8f937..354411226159eb251a067a5ff17491f85e6acd34 100644 (file)
@@ -1039,7 +1039,7 @@ config_generic(ConfigArgs *c) {
                        } else if ( !strcasecmp( c->argv[1], "frontend" )) {
                                c->be = frontendDB;
                        } else {
-                               c->be = backend_db_init(c->argv[1]);
+                               c->be = backend_db_init(c->argv[1], NULL);
                                if ( !c->be ) {
                                        snprintf( c->msg, sizeof( c->msg ), "<%s> failed init", c->argv[0] );
                                        Debug(LDAP_DEBUG_ANY, "%s: %s (%s)!\n",
@@ -2770,10 +2770,8 @@ config_setup_ldif( BackendDB *be, const char *dir, int readit ) {
        if ( !cfb->cb_db.bd_info )
                return 0;       /* FIXME: eventually this will be a fatal error */
 
-       if ( cfb->cb_db.bd_info->bi_db_init( &cfb->cb_db )) return 1;
-
-       /* Mark that back-ldif type is in use */
-       cfb->cb_db.bd_info->bi_nDB++;
+       if ( backend_db_init( "ldif", &cfb->cb_db ) == NULL )
+               return 1;
 
        cfb->cb_db.be_suffix = be->be_suffix;
        cfb->cb_db.be_nsuffix = be->be_nsuffix;
@@ -2880,7 +2878,7 @@ read_config(const char *fname, const char *dir) {
        int rc;
 
        /* Setup the config backend */
-       be = backend_db_init( "config" );
+       be = backend_db_init( "config", NULL );
        if ( !be )
                return 1;
 
index 3b594f96f49338a18760889ee0650a59dbfaf483..b34ab149ad97213a2a029a498dc1e5e592530452 100644 (file)
@@ -1799,21 +1799,11 @@ pc_cf_gen( ConfigArgs *c )
                        Debug( LDAP_DEBUG_ANY, "%s: %s\n", c->log, c->msg, 0 );
                        return( 1 );
                }
-               cm->db.bd_info = backend_info( c->argv[1] );
-               if ( !cm->db.bd_info ) {
+               if ( !backend_db_init( c->argv[1], &cm->db )) {
                        sprintf( c->msg, "unknown backend type" );
                        Debug( LDAP_DEBUG_ANY, "%s: %s\n", c->log, c->msg, 0 );
                        return( 1 );
                }
-               if ( cm->db.bd_info->bi_db_init( &cm->db ) ) {
-                       sprintf( c->msg, "backend %s init failed", c->argv[1] );
-                       Debug( LDAP_DEBUG_ANY, "%s: %s\n", c->log, c->msg, 0 );
-                       return( 1 );
-               }
-
-               /* This type is in use, needs to be opened */
-               cm->db.bd_info->bi_nDB++;
-
                cm->max_entries = atoi( c->argv[2] );
 
                cm->num_entries_limit = atoi( c->argv[4] );
index e1aac002ae840f66d247abdbf5a998ac0c23d2af..62cfceaa0a9ae3a81714039944ee1ac04c095c99 100644 (file)
@@ -321,7 +321,8 @@ LDAP_SLAPD_F (int) backend_destroy LDAP_P((void));
 LDAP_SLAPD_F (void) backend_destroy_one LDAP_P((BackendDB *bd, int dynamic));
 
 LDAP_SLAPD_F (BackendInfo *) backend_info LDAP_P(( const char *type ));
-LDAP_SLAPD_F (BackendDB *) backend_db_init LDAP_P(( const char *type ));
+LDAP_SLAPD_F (BackendDB *) backend_db_init LDAP_P(( const char *type,
+       BackendDB *be ));
 
 LDAP_SLAPD_F (BackendDB *) select_backend LDAP_P((
        struct berval * dn,