From: Howard Chu Date: Sat, 15 Dec 2001 12:05:58 +0000 (+0000) Subject: More thorough backend_destroy. Added config_destroy. Destroy slap_listeners. X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~649 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=826056e75bab39d888cc14d6bf80905eca9eb20d;p=openldap More thorough backend_destroy. Added config_destroy. Destroy slap_listeners. Plugged other small leaks. --- diff --git a/servers/slapd/backend.c b/servers/slapd/backend.c index 1162fa5a9a..5398d8e21d 100644 --- a/servers/slapd/backend.c +++ b/servers/slapd/backend.c @@ -417,7 +417,13 @@ int backend_destroy(void) backendDB[i].bd_info->bi_db_destroy( &backendDB[i] ); } + charray_free( backendDB[i].be_suffix ); + ber_bvecfree( backendDB[i].be_nsuffix ); + free( backendDB[i].be_root_dn ); + free( backendDB[i].be_root_ndn ); + free( backendDB[i].be_root_pw.bv_val ); } + free( backendDB ); /* destroy each backend type */ for( i = 0; i < nBackendInfo; i++ ) { diff --git a/servers/slapd/config.c b/servers/slapd/config.c index 45c6b36ee9..1cbb00fcf3 100644 --- a/servers/slapd/config.c +++ b/servers/slapd/config.c @@ -919,11 +919,12 @@ read_config( const char *fname ) #endif } else { - char *dn = ch_strdup( cargv[1] ); + char *dn; if ( load_ucdata( NULL ) < 0 ) { return( 1 ); } + dn = ch_strdup( cargv[1] ); if( dn_validate( dn ) == NULL ) { #ifdef NEW_LOGGING LDAP_LOG(( "config", LDAP_LEVEL_CRIT, @@ -934,7 +935,7 @@ read_config( const char *fname ) "suffix DN invalid \"%s\"\n", fname, lineno, cargv[1] ); #endif - + free( dn ); return 1; } else if( *dn == '\0' && default_search_nbase != NULL ) { @@ -966,6 +967,7 @@ read_config( const char *fname ) "unable to normalize suffix " "\"%s\"\n", dn, NULL, NULL ); #endif + free( dn ); return 1; } #endif /* USE_LDAP_DN_PARSING */ @@ -2370,3 +2372,14 @@ load_ucdata( char *path ) loaded = 1; return( 1 ); } + +void +config_destroy( ) +{ + ucdata_unload( UCDATA_ALL ); + free( line ); + if ( slapd_args_file ) + free ( slapd_args_file ); + if ( slapd_pid_file ) + free ( slapd_pid_file ); +} diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c index 3e71735c11..4b5ab5f973 100644 --- a/servers/slapd/daemon.c +++ b/servers/slapd/daemon.c @@ -1675,9 +1675,15 @@ slapd_daemon_task( } #endif /* LDAP_PF_LOCAL */ slapd_close( slap_listeners[l]->sl_sd ); - break; } + if ( slap_listeners[l]->sl_url ) + free ( slap_listeners[l]->sl_url ); + if ( slap_listeners[l]->sl_name ) + free ( slap_listeners[l]->sl_name ); + free ( slap_listeners[l] ); } + free ( slap_listeners ); + slap_listeners = NULL; #ifdef NEW_LOGGING LDAP_LOG(( "connection", LDAP_LEVEL_CRIT, diff --git a/servers/slapd/main.c b/servers/slapd/main.c index b71bb99d21..c46d0b2b6d 100644 --- a/servers/slapd/main.c +++ b/servers/slapd/main.c @@ -307,9 +307,9 @@ int main( int argc, char **argv ) if( serverName == NULL ) { if ( (serverName = strrchr( argv[0], *LDAP_DIRSEP )) == NULL ) { - serverName = ch_strdup( argv[0] ); + serverName = argv[0]; } else { - serverName = ch_strdup( serverName + 1 ); + serverName = serverName + 1; } } @@ -556,6 +556,8 @@ stop: ldap_pvt_tls_destroy(); #endif + config_destroy(); + #ifdef CSRIMALLOC mal_dumpleaktrace( leakfile ); #endif diff --git a/servers/slapd/sasl.c b/servers/slapd/sasl.c index 7a3b21921f..ea3dc20aa8 100644 --- a/servers/slapd/sasl.c +++ b/servers/slapd/sasl.c @@ -425,6 +425,9 @@ int slap_sasl_destroy( void ) #ifdef HAVE_CYRUS_SASL sasl_done(); #endif + free( global_host ); + global_host = NULL; + return 0; }