]> git.sur5r.net Git - openldap/commitdiff
destroy exactly what needs to
authorPierangelo Masarati <ando@openldap.org>
Thu, 14 Sep 2006 23:53:23 +0000 (23:53 +0000)
committerPierangelo Masarati <ando@openldap.org>
Thu, 14 Sep 2006 23:53:23 +0000 (23:53 +0000)
servers/slapd/backend.c
servers/slapd/overlays/pcache.c
servers/slapd/overlays/translucent.c
servers/slapd/proto-slap.h

index 0731e90215db5e4c749edbb112381fe3fec61706..64a23ab1d268644e03fd9599469dbb2f1c424583 100644 (file)
@@ -384,16 +384,18 @@ int backend_shutdown( Backend *be )
        return 0;
 }
 
-void backend_destroy_one( BackendDB *bd, int dynamic )
+/*
+ * This function is supposed to be the exact counterpart
+ * of backend_startup_one(), although this one calls bi_db_destroy()
+ * while backend_startup_one() calls bi_db_open().
+ *
+ * Make sure backend_stopdown_one() destroys resources allocated
+ * by backend_startup_one(); only call backend_destroy_one() when
+ * all stuff in a BackendDB needs to be destroyed
+ */
+void
+backend_stopdown_one( BackendDB *bd )
 {
-       if ( dynamic ) {
-               LDAP_STAILQ_REMOVE(&backendDB, bd, slap_backend_db, be_next );
-       }
-
-       if ( bd->be_syncinfo ) {
-               syncinfo_free( bd->be_syncinfo );
-       }
-
        if ( bd->be_pending_csn_list ) {
                struct slap_csn_entry *csne;
                csne = LDAP_TAILQ_FIRST( bd->be_pending_csn_list );
@@ -411,6 +413,20 @@ void backend_destroy_one( BackendDB *bd, int dynamic )
        if ( bd->bd_info->bi_db_destroy ) {
                bd->bd_info->bi_db_destroy( bd );
        }
+}
+
+void backend_destroy_one( BackendDB *bd, int dynamic )
+{
+       if ( dynamic ) {
+               LDAP_STAILQ_REMOVE(&backendDB, bd, slap_backend_db, be_next );
+       }
+
+       if ( bd->be_syncinfo ) {
+               syncinfo_free( bd->be_syncinfo );
+       }
+
+       backend_stopdown_one( bd );
+
        ber_bvarray_free( bd->be_suffix );
        ber_bvarray_free( bd->be_nsuffix );
        if ( !BER_BVISNULL( &bd->be_rootdn ) ) {
index b2265df22c3bb7e7bae7d062791341e5251483cf..ec2d97910a95818a0683c4d5cba326c6c18639fe 100644 (file)
@@ -2301,16 +2301,8 @@ pcache_db_destroy(
        cache_manager *cm = on->on_bi.bi_private;
        query_manager *qm = cm->qm;
 
-       /* cleanup stuff inherited from the original database... */
-       cm->db.be_suffix = NULL;
-       cm->db.be_nsuffix = NULL;
-       BER_BVZERO( &cm->db.be_rootdn );
-       BER_BVZERO( &cm->db.be_rootndn );
-       BER_BVZERO( &cm->db.be_rootpw );
-       /* FIXME: there might be more... */
-
        if ( cm->db.be_private != NULL ) {
-               backend_destroy_one( &cm->db, 0 );
+               backend_stopdown_one( &cm->db );
        }
 
        ldap_pvt_thread_mutex_destroy( &qm->lru_mutex );
index bc560aba0775768ff95834e017ae8bd8a38a6ed5..4b908c13672d1261692fa00ba8aa780b2f127768 100644 (file)
@@ -773,16 +773,8 @@ translucent_db_destroy( BackendDB *be )
        Debug(LDAP_DEBUG_TRACE, "==> translucent_db_close\n", 0, 0, 0);
 
        if ( ov ) {
-               /* cleanup stuff inherited from the original database... */
-               ov->db.be_suffix = NULL;
-               ov->db.be_nsuffix = NULL;
-               BER_BVZERO( &ov->db.be_rootdn );
-               BER_BVZERO( &ov->db.be_rootndn );
-               BER_BVZERO( &ov->db.be_rootpw );
-               /* FIXME: there might be more... */
-
                if ( ov->db.be_private != NULL ) {
-                       backend_destroy_one( &ov->db, 0 );
+                       backend_stopdown_one( &ov->db );
                }
 
                ch_free(ov);
index 6728c9690789f3ff99f0198efadc7f2d551194e5..05ea1defb77e01f968928b83fbc369392aa9da16 100644 (file)
@@ -316,6 +316,7 @@ 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));
+LDAP_SLAPD_F (void) backend_stopdown_one LDAP_P((BackendDB *bd ));
 LDAP_SLAPD_F (void) backend_destroy_one LDAP_P((BackendDB *bd, int dynamic));
 
 LDAP_SLAPD_F (BackendInfo *) backend_info LDAP_P(( const char *type ));