From e549e4463ad465481a9fac4ba1f9c86f004b61b9 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Sun, 7 Aug 2005 15:01:13 +0000 Subject: [PATCH] free replica info as appropriate --- servers/slapd/ad.c | 9 +++++--- servers/slapd/backend.c | 8 +++++++ servers/slapd/proto-slap.h | 1 + servers/slapd/repl.c | 46 ++++++++++++++++++++++++++++++++++---- 4 files changed, 57 insertions(+), 7 deletions(-) diff --git a/servers/slapd/ad.c b/servers/slapd/ad.c index c690d2efdb..a067e059cc 100644 --- a/servers/slapd/ad.c +++ b/servers/slapd/ad.c @@ -775,13 +775,16 @@ str2anlist( AttributeName *an, char *in, const char *brkstr ) AttributeName *anew; /* find last element in list */ - for (i = 0; an && an[i].an_name.bv_val; i++); + if ( an != NULL ) { + for ( i = 0; !BER_BVISNULL( &an[ i ].an_name ) ; i++) + ; + } /* protect the input string from strtok */ str = ch_strdup( in ); /* Count words in string */ - j=1; + j = 1; for ( s = str; *s; s++ ) { if ( strchr( brkstr, *s ) != NULL ) { j++; @@ -839,7 +842,7 @@ str2anlist( AttributeName *an, char *in, const char *brkstr ) anew++; } - anew->an_name.bv_val = NULL; + BER_BVZERO( &anew->an_name ); free( str ); return( an ); diff --git a/servers/slapd/backend.c b/servers/slapd/backend.c index cd32557290..b5204ce7bc 100644 --- a/servers/slapd/backend.c +++ b/servers/slapd/backend.c @@ -422,6 +422,11 @@ void backend_destroy_one( BackendDB *bd, int dynamic ) } acl_destroy( bd->be_acl, frontendDB->be_acl ); limits_destroy( bd->be_limits ); + if ( bd->be_replogfile ) { + ch_free( bd->be_replogfile ); + } + destroy_replica_info( bd ); + if ( dynamic ) { free( bd ); } @@ -465,6 +470,9 @@ int backend_destroy(void) free( bd->be_rootpw.bv_val ); } acl_destroy( bd->be_acl, frontendDB->be_acl ); + + assert( bd->be_replogfile == NULL ); + assert( bd->be_replica == NULL ); } return 0; diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index ce907de38b..1902de4d4c 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -1228,6 +1228,7 @@ LDAP_SLAPD_F (int) get_alias_dn LDAP_P(( */ LDAP_SLAPD_F (int) add_replica_info LDAP_P(( Backend *be, const char *uri, const char *host )); +LDAP_SLAPD_F (int) destroy_replica_info LDAP_P (( Backend *be )); LDAP_SLAPD_F (int) add_replica_suffix LDAP_P(( Backend *be, int nr, const char *suffix )); LDAP_SLAPD_F (int) add_replica_attrs LDAP_P(( Backend *be, diff --git a/servers/slapd/repl.c b/servers/slapd/repl.c index cfc2cb3d3b..e269539f65 100644 --- a/servers/slapd/repl.c +++ b/servers/slapd/repl.c @@ -41,10 +41,9 @@ int add_replica_info( - Backend *be, - const char *uri, - const char *host -) + Backend *be, + const char *uri, + const char *host ) { int i = 0; @@ -69,6 +68,45 @@ add_replica_info( return( i ); } +int +destroy_replica_info( + Backend *be ) +{ + int i = 0; + + assert( be ); + + if ( be->be_replica == NULL ) { + return 0; + } + + for ( ; be->be_replica[ i ] != NULL; i++ ) { + + ch_free( (char *)be->be_replica[ i ]->ri_uri ); + + ber_bvarray_free( be->be_replica[ i ]->ri_nsuffix ); + + if ( be->be_replica[ i ]->ri_attrs ) { + AttributeName *an = be->be_replica[ i ]->ri_attrs; + int j; + + for ( j = 0; !BER_BVISNULL( &an[ j ].an_name ); j++ ) + { + ch_free( an[ j ].an_name.bv_val ); + } + ch_free( an ); + } + + bindconf_free( &be->be_replica[ i ]->ri_bindconf ); + + ch_free( be->be_replica[ i ] ); + } + + ch_free( be->be_replica ); + + return 0; +} + int add_replica_suffix( Backend *be, -- 2.39.5