From: Howard Chu Date: Mon, 12 Jul 2004 20:27:33 +0000 (+0000) Subject: Add backend_startup_one() X-Git-Tag: OPENDLAP_REL_ENG_2_2_MP~79 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=2954a90483897d2d95c15e72032f163d060f4f7f;p=openldap Add backend_startup_one() --- diff --git a/servers/slapd/backend.c b/servers/slapd/backend.c index fcc4378228..1119d2ec84 100644 --- a/servers/slapd/backend.c +++ b/servers/slapd/backend.c @@ -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; diff --git a/servers/slapd/overlays/pcache.c b/servers/slapd/overlays/pcache.c index b43fb42ae2..ae2448a7de 100644 --- a/servers/slapd/overlays/pcache.c +++ b/servers/slapd/overlays/pcache.c @@ -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 ) { diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index c7c8dbcd61..26897f1377 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -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));