]> git.sur5r.net Git - openldap/commitdiff
Add backend_startup_one()
authorHoward Chu <hyc@openldap.org>
Mon, 12 Jul 2004 20:27:33 +0000 (20:27 +0000)
committerHoward Chu <hyc@openldap.org>
Mon, 12 Jul 2004 20:27:33 +0000 (20:27 +0000)
servers/slapd/backend.c
servers/slapd/overlays/pcache.c
servers/slapd/proto-slap.h

index fcc437822858bd5b6ffa4c6c0ac784e670092f5d..1119d2ec84db5af1d0aa1a0bb3124d1f48aba468 100644 (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;
index b43fb42ae2a9a681672b8d82815c840d10d91469..ae2448a7de55b201e5f578b6f2bab5c0822cf396 100644 (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 ) {
index c7c8dbcd61d7643b947df04c16d05fa989fb1ed0..26897f1377d27777fbc358bd1592e025ee33b307 100644 (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));