Add backend_startup_one()

This commit is contained in:
Howard Chu 2004-07-12 20:27:33 +00:00
parent 856a8c1177
commit 2954a90483
3 changed files with 49 additions and 68 deletions

View File

@ -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;

View File

@ -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 ) {

View File

@ -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));