From: Pierangelo Masarati Date: Thu, 14 Sep 2006 23:53:23 +0000 (+0000) Subject: destroy exactly what needs to X-Git-Tag: OPENLDAP_REL_ENG_2_3_MP~128 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=4add034d5d25d634ada25ee02e771011649ab392;p=openldap destroy exactly what needs to --- diff --git a/servers/slapd/backend.c b/servers/slapd/backend.c index 0731e90215..64a23ab1d2 100644 --- a/servers/slapd/backend.c +++ b/servers/slapd/backend.c @@ -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 ) ) { diff --git a/servers/slapd/overlays/pcache.c b/servers/slapd/overlays/pcache.c index b2265df22c..ec2d97910a 100644 --- a/servers/slapd/overlays/pcache.c +++ b/servers/slapd/overlays/pcache.c @@ -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 ); diff --git a/servers/slapd/overlays/translucent.c b/servers/slapd/overlays/translucent.c index bc560aba07..4b908c1367 100644 --- a/servers/slapd/overlays/translucent.c +++ b/servers/slapd/overlays/translucent.c @@ -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); diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 6728c96907..05ea1defb7 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -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 ));