BackendDB *
backend_db_init(
- const char *type )
+ const char *type,
+ BackendDB *be )
{
- Backend *be;
BackendInfo *bi = backend_info(type);
int rc = 0;
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;
} 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",
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;
int rc;
/* Setup the config backend */
- be = backend_db_init( "config" );
+ be = backend_db_init( "config", NULL );
if ( !be )
return 1;
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,