Plug more memleaks

This commit is contained in:
Howard Chu 2005-07-21 23:26:40 +00:00
parent a70c294359
commit ddf6c7b298
6 changed files with 36 additions and 14 deletions

View File

@ -295,11 +295,12 @@ alock_query_slot ( alock_info_t * info )
(void) memset ((void *) &slot_data, 0, sizeof (alock_slot_t)); (void) memset ((void *) &slot_data, 0, sizeof (alock_slot_t));
alock_read_slot (info, &slot_data); 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); if (slot_data.al_appname != NULL) free (slot_data.al_appname);
slot_data.al_appname = NULL; 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); res = alock_test_lock (info->al_fd, info->al_slot);
if (res < 0) return -1; if (res < 0) return -1;
if (res > 0) { if (res > 0) {

View File

@ -1164,6 +1164,8 @@ ldif_back_db_destroy(
) )
{ {
struct ldif_info *ni = be->be_private; struct ldif_info *ni = be->be_private;
ch_free(ni->li_base_path.bv_val);
ldap_pvt_thread_mutex_destroy(&ni->li_mutex); ldap_pvt_thread_mutex_destroy(&ni->li_mutex);
free( be->be_private ); free( be->be_private );
return 0; return 0;

View File

@ -382,9 +382,11 @@ int backend_shutdown( Backend *be )
return 0; 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 ) { if ( bd->be_syncinfo ) {
syncinfo_free( 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 ); csne = LDAP_TAILQ_NEXT( csne, ce_csn_link );
ch_free( tmp_csne ); ch_free( tmp_csne );
} }
ch_free( bd->be_pending_csn_list );
} }
if ( bd->bd_info->bi_db_destroy ) { if ( bd->bd_info->bi_db_destroy ) {
@ -418,7 +421,9 @@ void backend_destroy_one( BackendDB *bd )
free( bd->be_rootpw.bv_val ); free( bd->be_rootpw.bv_val );
} }
acl_destroy( bd->be_acl, frontendDB->be_acl ); acl_destroy( bd->be_acl, frontendDB->be_acl );
free( bd ); if ( dynamic ) {
free( bd );
}
} }
int backend_destroy(void) int backend_destroy(void)
@ -428,7 +433,7 @@ int backend_destroy(void)
/* destroy each backend database */ /* destroy each backend database */
while (( bd = LDAP_STAILQ_FIRST(&backendDB))) { while (( bd = LDAP_STAILQ_FIRST(&backendDB))) {
backend_destroy_one( bd ); backend_destroy_one( bd, 1 );
} }
/* destroy each backend type */ /* destroy each backend type */

View File

@ -2541,6 +2541,8 @@ config_setup_ldif( BackendDB *be, const char *dir, int readit ) {
op->o_bd = &cfb->cb_db; op->o_bd = &cfb->cb_db;
rc = op->o_bd->be_search( op, &rs ); rc = op->o_bd->be_search( op, &rs );
slap_sl_mem_destroy( NULL, op->o_tmpmemctx );
} }
cfb->cb_use_ldif = 1; cfb->cb_use_ldif = 1;
@ -3218,7 +3220,7 @@ ok:
leave: leave:
if ( rc ) { if ( rc ) {
if ( (colst[0]->co_type == Cft_Database) && ca->be ) { 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 ) { } else if ( (colst[0]->co_type == Cft_Overlay) && ca->bi ) {
overlay_destroy_one( ca->be, (slap_overinst *)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; return 0;
} }
@ -4044,21 +4048,30 @@ config_back_db_close( BackendDB *be )
{ {
CfBackInfo *cfb = be->be_private; 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_free_entries( cfb->cb_root );
cfb->cb_root = NULL; cfb->cb_root = NULL;
backend_shutdown( &cfb->cb_db );
return 0; return 0;
} }
static int static int
config_back_db_destroy( BackendDB *be ) 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 ); free( be->be_private );
return 0; return 0;
} }

View File

@ -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_sync LDAP_P((Backend *be));
LDAP_SLAPD_F (int) backend_shutdown 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 (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 (BackendInfo *) backend_info LDAP_P(( const char *type ));
LDAP_SLAPD_F (BackendDB *) backend_db_init LDAP_P(( const char *type )); LDAP_SLAPD_F (BackendDB *) backend_db_init LDAP_P(( const char *type ));

View File

@ -385,6 +385,7 @@ ordered_value_sort( Attribute *a, int do_renumber )
if ( indexes[0] != 0 || indexes[vals-1] != vals-1 ) { if ( indexes[0] != 0 || indexes[vals-1] != vals-1 ) {
renumber = 1; renumber = 1;
} }
ch_free( indexes );
} else { } else {
renumber = 1; renumber = 1;
} }