Commit 2954a904 authored by Howard Chu's avatar Howard Chu
Browse files

Add backend_startup_one()

parent 856a8c11
......@@ -279,6 +279,46 @@ int backend_add(BackendInfo *aBackendInfo)
}
}
/* startup a specific backend database */
int backend_startup_one(Backend *be)
{
int rc = 0;
assert(be);
be->be_pending_csn_list = (struct be_pcl *)
ch_calloc( 1, sizeof( struct be_pcl ));
build_new_dn( &be->be_context_csn, be->be_nsuffix,
(struct berval *)&slap_ldapsync_cn_bv, NULL );
LDAP_TAILQ_INIT( be->be_pending_csn_list );
#ifdef NEW_LOGGING
LDAP_LOG( BACKEND, DETAIL1, "backend_startup: starting \"%s\"\n",
be->be_suffix ? be->be_suffix[0].bv_val : "(unknown)",
0, 0 );
#else
Debug( LDAP_DEBUG_TRACE,
"backend_startup: starting \"%s\"\n",
be->be_suffix ? be->be_suffix[0].bv_val : "(unknown)",
0, 0 );
#endif
if ( be->bd_info->bi_db_open ) {
rc = be->bd_info->bi_db_open( be );
if ( rc != 0 ) {
#ifdef NEW_LOGGING
LDAP_LOG( BACKEND, CRIT,
"backend_startup: bi_db_open failed! (%d)\n", rc, 0, 0 );
#else
Debug( LDAP_DEBUG_ANY,
"backend_startup: bi_db_open failed! (%d)\n",
rc, 0, 0 );
#endif
}
}
return rc;
}
int backend_startup(Backend *be)
{
int i;
......@@ -298,25 +338,6 @@ int backend_startup(Backend *be)
}
if(be != NULL) {
/* startup a specific backend database */
be->be_pending_csn_list = (struct be_pcl *)
ch_calloc( 1, sizeof( struct be_pcl ));
build_new_dn( &be->be_context_csn, be->be_nsuffix,
(struct berval *)&slap_ldapsync_cn_bv, NULL );
LDAP_TAILQ_INIT( be->be_pending_csn_list );
#ifdef NEW_LOGGING
LDAP_LOG( BACKEND, DETAIL1, "backend_startup: starting \"%s\"\n",
be->be_suffix ? be->be_suffix[0].bv_val : "(unknown)",
0, 0 );
#else
Debug( LDAP_DEBUG_TRACE,
"backend_startup: starting \"%s\"\n",
be->be_suffix ? be->be_suffix[0].bv_val : "(unknown)",
0, 0 );
#endif
if ( be->bd_info->bi_open ) {
rc = be->bd_info->bi_open( be->bd_info );
if ( rc != 0 ) {
......@@ -333,22 +354,7 @@ int backend_startup(Backend *be)
}
}
if ( be->bd_info->bi_db_open ) {
rc = be->bd_info->bi_db_open( be );
if ( rc != 0 ) {
#ifdef NEW_LOGGING
LDAP_LOG( BACKEND, CRIT,
"backend_startup: bi_db_open failed! (%d)\n", rc, 0, 0 );
#else
Debug( LDAP_DEBUG_ANY,
"backend_startup: bi_db_open failed! (%d)\n",
rc, 0, 0 );
#endif
return rc;
}
}
return rc;
return backend_startup_one( be );
}
/* open each backend type */
......@@ -381,13 +387,6 @@ int backend_startup(Backend *be)
/* open each backend database */
for( i = 0; i < nBackendDB; i++ ) {
/* append global access controls */
acl_append( &backendDB[i].be_acl, global_acl );
backendDB[i].be_pending_csn_list = (struct be_pcl *)
ch_calloc( 1, sizeof( struct be_pcl ));
LDAP_TAILQ_INIT( backendDB[i].be_pending_csn_list );
if ( backendDB[i].be_suffix == NULL ) {
#ifdef NEW_LOGGING
LDAP_LOG( BACKEND, CRIT,
......@@ -401,25 +400,13 @@ int backend_startup(Backend *be)
i, backendDB[i].bd_info->bi_type, 0 );
#endif
}
build_new_dn( &backendDB[i].be_context_csn, backendDB[i].be_nsuffix,
(struct berval *)&slap_ldapsync_cn_bv, NULL );
/* append global access controls */
acl_append( &backendDB[i].be_acl, global_acl );
rc = backend_startup_one( &backendDB[i] );
if ( rc ) return rc;
if ( backendDB[i].bd_info->bi_db_open ) {
rc = backendDB[i].bd_info->bi_db_open(
&backendDB[i] );
if ( rc != 0 ) {
#ifdef NEW_LOGGING
LDAP_LOG( BACKEND, CRIT,
"backend_startup: bi_db_open(%d) failed! (%d)\n",
i, rc, 0 );
#else
Debug( LDAP_DEBUG_ANY,
"backend_startup: bi_db_open(%d) failed! (%d)\n",
i, rc, 0 );
#endif
return rc;
}
}
if ( !LDAP_STAILQ_EMPTY( &backendDB[i].be_syncinfo )) {
syncinfo_t *si;
......
......@@ -1866,14 +1866,7 @@ proxy_cache_open(
cache_manager *cm = on->on_bi.bi_private;
int rc = 0;
if ( cm->db.bd_info->bi_db_open ) {
cm->db.be_pending_csn_list = (struct be_pcl *)
ch_calloc( 1, sizeof( struct be_pcl ));
LDAP_TAILQ_INIT( cm->db.be_pending_csn_list );
build_new_dn( &cm->db.be_context_csn, be->be_nsuffix,
(struct berval *)&slap_ldapsync_cn_bv, NULL );
rc = cm->db.bd_info->bi_db_open( &cm->db );
}
rc = backend_startup_one( &cm->db );
/* There is no runqueue in TOOL mode */
if ( slapMode & SLAP_SERVER_MODE ) {
......
......@@ -210,6 +210,7 @@ LDAP_SLAPD_F (int) backend_init LDAP_P((void));
LDAP_SLAPD_F (int) backend_add LDAP_P((BackendInfo *aBackendInfo));
LDAP_SLAPD_F (int) backend_num LDAP_P((Backend *be));
LDAP_SLAPD_F (int) backend_startup LDAP_P((Backend *be));
LDAP_SLAPD_F (int) backend_startup_one LDAP_P((Backend *be));
LDAP_SLAPD_F (int) backend_sync LDAP_P((Backend *be));
LDAP_SLAPD_F (int) backend_shutdown LDAP_P((Backend *be));
LDAP_SLAPD_F (int) backend_destroy LDAP_P((void));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment