mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-01-06 10:46:21 +08:00
ITS#3774 delete backend/overlay structures after a failed add
This commit is contained in:
parent
ba8b6bbd88
commit
f84fc983fd
@ -392,49 +392,54 @@ int backend_shutdown( Backend *be )
|
||||
return 0;
|
||||
}
|
||||
|
||||
void backend_destroy_one( BackendDB *bd )
|
||||
{
|
||||
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 );
|
||||
while ( csne ) {
|
||||
struct slap_csn_entry *tmp_csne = csne;
|
||||
|
||||
LDAP_TAILQ_REMOVE( bd->be_pending_csn_list, csne, ce_csn_link );
|
||||
ch_free( csne->ce_csn.bv_val );
|
||||
csne = LDAP_TAILQ_NEXT( csne, ce_csn_link );
|
||||
ch_free( tmp_csne );
|
||||
}
|
||||
}
|
||||
|
||||
if ( bd->bd_info->bi_db_destroy ) {
|
||||
bd->bd_info->bi_db_destroy( bd );
|
||||
}
|
||||
ber_bvarray_free( bd->be_suffix );
|
||||
ber_bvarray_free( bd->be_nsuffix );
|
||||
if ( !BER_BVISNULL( &bd->be_rootdn ) ) {
|
||||
free( bd->be_rootdn.bv_val );
|
||||
}
|
||||
if ( !BER_BVISNULL( &bd->be_rootndn ) ) {
|
||||
free( bd->be_rootndn.bv_val );
|
||||
}
|
||||
if ( !BER_BVISNULL( &bd->be_rootpw ) ) {
|
||||
free( bd->be_rootpw.bv_val );
|
||||
}
|
||||
acl_destroy( bd->be_acl, frontendDB->be_acl );
|
||||
free( bd );
|
||||
}
|
||||
|
||||
int backend_destroy(void)
|
||||
{
|
||||
int i;
|
||||
BackendDB *bd;
|
||||
BackendInfo *bi;
|
||||
struct slap_csn_entry *csne;
|
||||
|
||||
/* destroy each backend database */
|
||||
while (( bd = LDAP_STAILQ_FIRST(&backendDB))) {
|
||||
LDAP_STAILQ_REMOVE_HEAD(&backendDB, be_next);
|
||||
|
||||
if ( bd->be_syncinfo ) {
|
||||
syncinfo_free( bd->be_syncinfo );
|
||||
}
|
||||
|
||||
if ( bd->be_pending_csn_list ) {
|
||||
csne = LDAP_TAILQ_FIRST( bd->be_pending_csn_list );
|
||||
while ( csne ) {
|
||||
struct slap_csn_entry *tmp_csne = csne;
|
||||
|
||||
LDAP_TAILQ_REMOVE( bd->be_pending_csn_list, csne, ce_csn_link );
|
||||
ch_free( csne->ce_csn.bv_val );
|
||||
csne = LDAP_TAILQ_NEXT( csne, ce_csn_link );
|
||||
ch_free( tmp_csne );
|
||||
}
|
||||
}
|
||||
|
||||
if ( bd->bd_info->bi_db_destroy ) {
|
||||
bd->bd_info->bi_db_destroy( bd );
|
||||
}
|
||||
ber_bvarray_free( bd->be_suffix );
|
||||
ber_bvarray_free( bd->be_nsuffix );
|
||||
if ( !BER_BVISNULL( &bd->be_rootdn ) ) {
|
||||
free( bd->be_rootdn.bv_val );
|
||||
}
|
||||
if ( !BER_BVISNULL( &bd->be_rootndn ) ) {
|
||||
free( bd->be_rootndn.bv_val );
|
||||
}
|
||||
if ( !BER_BVISNULL( &bd->be_rootpw ) ) {
|
||||
free( bd->be_rootpw.bv_val );
|
||||
}
|
||||
acl_destroy( bd->be_acl, frontendDB->be_acl );
|
||||
free( bd );
|
||||
backend_destroy_one( bd );
|
||||
}
|
||||
|
||||
/* destroy each backend type */
|
||||
|
@ -659,6 +659,27 @@ overlay_register_control( BackendDB *be, const char *oid )
|
||||
return rc;
|
||||
}
|
||||
|
||||
void
|
||||
overlay_destroy_one( BackendDB *be, slap_overinst *on )
|
||||
{
|
||||
slap_overinfo *oi = on->on_info;
|
||||
slap_overinst **oidx;
|
||||
|
||||
for ( oidx = &oi->oi_list; *oidx; oidx = &(*oidx)->on_next ) {
|
||||
if ( *oidx == on ) {
|
||||
*oidx = on->on_next;
|
||||
if ( on->on_bi.bi_db_destroy ) {
|
||||
BackendInfo *bi_orig = be->bd_info;
|
||||
be->bd_info = (BackendInfo *)on;
|
||||
on->on_bi.bi_db_destroy( be );
|
||||
be->bd_info = bi_orig;
|
||||
}
|
||||
free( on );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* add an overlay to a particular backend. */
|
||||
int
|
||||
overlay_config( BackendDB *be, const char *ov )
|
||||
|
@ -3169,6 +3169,10 @@ ok:
|
||||
Debug(LDAP_DEBUG_ANY, "%s: %s (%s)!\n",
|
||||
ca->log, ca->msg, ca->argv[1] );
|
||||
rc = LDAP_OTHER;
|
||||
if ( colst[0]->co_type == Cft_Database )
|
||||
backend_destroy_one( ca->be );
|
||||
else
|
||||
overlay_destroy_one( ca->be, (slap_overinst *)ca->bi );
|
||||
goto leave;
|
||||
}
|
||||
}
|
||||
|
@ -258,6 +258,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_destroy_one LDAP_P((BackendDB *bd));
|
||||
|
||||
LDAP_SLAPD_F (BackendInfo *) backend_info LDAP_P(( const char *type ));
|
||||
LDAP_SLAPD_F (BackendDB *) backend_db_init LDAP_P(( const char *type ));
|
||||
@ -348,6 +349,9 @@ LDAP_SLAPD_F (int) glue_sub_init( void );
|
||||
|
||||
LDAP_SLAPD_F (int) overlay_register LDAP_P(( slap_overinst *on ));
|
||||
LDAP_SLAPD_F (int) overlay_config LDAP_P(( BackendDB *be, const char *ov ));
|
||||
LDAP_SLAPD_F (void) overlay_destroy_one LDAP_P((
|
||||
BackendDB *be,
|
||||
slap_overinst *on ));
|
||||
LDAP_SLAPD_F (slap_overinst *) overlay_next LDAP_P(( slap_overinst *on ));
|
||||
LDAP_SLAPD_F (slap_overinst *) overlay_find LDAP_P(( const char *name ));
|
||||
LDAP_SLAPD_F (int) overlay_is_over LDAP_P(( BackendDB *be ));
|
||||
|
Loading…
Reference in New Issue
Block a user