diff --git a/servers/slapd/back-bdb/alock.c b/servers/slapd/back-bdb/alock.c index 4951e8ffab..1410413e9e 100644 --- a/servers/slapd/back-bdb/alock.c +++ b/servers/slapd/back-bdb/alock.c @@ -295,11 +295,12 @@ alock_query_slot ( alock_info_t * info ) (void) memset ((void *) &slot_data, 0, sizeof (alock_slot_t)); alock_read_slot (info, &slot_data); - if (slot_data.al_lock == ALOCK_UNLOCKED) return ALOCK_UNLOCKED; if (slot_data.al_appname != NULL) free (slot_data.al_appname); slot_data.al_appname = NULL; + if (slot_data.al_lock == ALOCK_UNLOCKED) return ALOCK_UNLOCKED; + res = alock_test_lock (info->al_fd, info->al_slot); if (res < 0) return -1; if (res > 0) { diff --git a/servers/slapd/back-ldif/ldif.c b/servers/slapd/back-ldif/ldif.c index fa5ee9b031..9e9145d648 100644 --- a/servers/slapd/back-ldif/ldif.c +++ b/servers/slapd/back-ldif/ldif.c @@ -1164,6 +1164,8 @@ ldif_back_db_destroy( ) { struct ldif_info *ni = be->be_private; + + ch_free(ni->li_base_path.bv_val); ldap_pvt_thread_mutex_destroy(&ni->li_mutex); free( be->be_private ); return 0; diff --git a/servers/slapd/backend.c b/servers/slapd/backend.c index a2e476ded1..3840ea02e9 100644 --- a/servers/slapd/backend.c +++ b/servers/slapd/backend.c @@ -382,9 +382,11 @@ int backend_shutdown( Backend *be ) return 0; } -void backend_destroy_one( BackendDB *bd ) +void backend_destroy_one( BackendDB *bd, int dynamic ) { - LDAP_STAILQ_REMOVE(&backendDB, bd, slap_backend_db, be_next ); + if ( dynamic ) { + LDAP_STAILQ_REMOVE(&backendDB, bd, slap_backend_db, be_next ); + } if ( bd->be_syncinfo ) { syncinfo_free( bd->be_syncinfo ); @@ -401,6 +403,7 @@ void backend_destroy_one( BackendDB *bd ) csne = LDAP_TAILQ_NEXT( csne, ce_csn_link ); ch_free( tmp_csne ); } + ch_free( bd->be_pending_csn_list ); } if ( bd->bd_info->bi_db_destroy ) { @@ -418,7 +421,9 @@ void backend_destroy_one( BackendDB *bd ) free( bd->be_rootpw.bv_val ); } acl_destroy( bd->be_acl, frontendDB->be_acl ); - free( bd ); + if ( dynamic ) { + free( bd ); + } } int backend_destroy(void) @@ -428,7 +433,7 @@ int backend_destroy(void) /* destroy each backend database */ while (( bd = LDAP_STAILQ_FIRST(&backendDB))) { - backend_destroy_one( bd ); + backend_destroy_one( bd, 1 ); } /* destroy each backend type */ diff --git a/servers/slapd/bconfig.c b/servers/slapd/bconfig.c index 430ef92831..1ba2f24c14 100644 --- a/servers/slapd/bconfig.c +++ b/servers/slapd/bconfig.c @@ -2541,6 +2541,8 @@ config_setup_ldif( BackendDB *be, const char *dir, int readit ) { op->o_bd = &cfb->cb_db; rc = op->o_bd->be_search( op, &rs ); + + slap_sl_mem_destroy( NULL, op->o_tmpmemctx ); } cfb->cb_use_ldif = 1; @@ -3218,7 +3220,7 @@ ok: leave: if ( rc ) { if ( (colst[0]->co_type == Cft_Database) && ca->be ) { - backend_destroy_one( ca->be ); + backend_destroy_one( ca->be, 1 ); } else if ( (colst[0]->co_type == Cft_Overlay) && ca->bi ) { overlay_destroy_one( ca->be, (slap_overinst *)ca->bi ); } @@ -4005,6 +4007,8 @@ config_back_db_open( BackendDB *be ) } } } + if ( op ) + slap_sl_mem_destroy( NULL, op->o_tmpmemctx ); return 0; } @@ -4044,21 +4048,30 @@ config_back_db_close( BackendDB *be ) { CfBackInfo *cfb = be->be_private; - /* Note - this is asymmetric; cfb->cb_config was allocated in db_init - * not db_open. We cannot re-open this DB after a close. (Not that we - * ever could anyway.) - */ - cfb_free_cffile( cfb->cb_config ); - cfb->cb_config = NULL; - cfb_free_entries( cfb->cb_root ); cfb->cb_root = NULL; + + backend_shutdown( &cfb->cb_db ); return 0; } static int config_back_db_destroy( BackendDB *be ) { + CfBackInfo *cfb = be->be_private; + + cfb_free_cffile( cfb->cb_config ); + + ch_free( cfdir.bv_val ); + + avl_free( CfOcTree, NULL ); + + cfb->cb_db.be_suffix = NULL; + cfb->cb_db.be_nsuffix = NULL; + cfb->cb_db.be_rootdn.bv_val = NULL; + cfb->cb_db.be_rootndn.bv_val = NULL; + backend_destroy_one( &cfb->cb_db, 0 ); + free( be->be_private ); return 0; } diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index b571762887..39b4cef113 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -264,7 +264,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 (void) backend_destroy_one LDAP_P((BackendDB *bd, int dynamic)); LDAP_SLAPD_F (BackendInfo *) backend_info LDAP_P(( const char *type )); LDAP_SLAPD_F (BackendDB *) backend_db_init LDAP_P(( const char *type )); diff --git a/servers/slapd/value.c b/servers/slapd/value.c index 174a30579d..aab6b34bc8 100644 --- a/servers/slapd/value.c +++ b/servers/slapd/value.c @@ -385,6 +385,7 @@ ordered_value_sort( Attribute *a, int do_renumber ) if ( indexes[0] != 0 || indexes[vals-1] != vals-1 ) { renumber = 1; } + ch_free( indexes ); } else { renumber = 1; }