From a6d4a827821214c2a27cd770868b24671f2be64b Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Sun, 7 Aug 2005 15:20:14 +0000 Subject: [PATCH] more about freeing replica resources --- servers/slapd/backend.c | 6 ++++++ servers/slapd/bconfig.c | 18 +++++++----------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/servers/slapd/backend.c b/servers/slapd/backend.c index b5204ce7bc..e100b60022 100644 --- a/servers/slapd/backend.c +++ b/servers/slapd/backend.c @@ -426,6 +426,12 @@ void backend_destroy_one( BackendDB *bd, int dynamic ) ch_free( bd->be_replogfile ); } destroy_replica_info( bd ); + if ( !BER_BVISNULL( &bd->be_update_ndn ) ) { + ch_free( bd->be_update_ndn.bv_val ); + } + if ( bd->be_update_refs ) { + ber_bvarray_free( bd->be_update_refs ); + } if ( dynamic ) { free( bd ); diff --git a/servers/slapd/bconfig.c b/servers/slapd/bconfig.c index 472f7b4ccf..77d9065f01 100644 --- a/servers/slapd/bconfig.c +++ b/servers/slapd/bconfig.c @@ -2292,7 +2292,7 @@ config_updatedn(ConfigArgs *c) { return 1; } else if ( c->op == LDAP_MOD_DELETE ) { ch_free( c->be->be_update_ndn.bv_val ); - c->be->be_update_ndn.bv_val = NULL; + BER_BVZERO( &c->be->be_update_ndn ); SLAP_DBFLAGS(c->be) ^= (SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SLURP_SHADOW); return 0; } @@ -2303,17 +2303,13 @@ config_updatedn(ConfigArgs *c) { return(1); } - ber_str2bv(c->argv[1], 0, 0, &dn); - - rc = dnNormalize(0, NULL, NULL, &dn, &c->be->be_update_ndn, NULL); - - if(rc != LDAP_SUCCESS) { - sprintf( c->msg, "<%s> invalid DN %d (%s)", c->argv[0], - rc, ldap_err2string(rc)); - Debug(LDAP_DEBUG_ANY, "%s: %s\n", - c->log, c->msg, 0 ); - return(1); + ber_memfree_x( c->value_dn.bv_val, NULL ); + if ( !BER_BVISNULL( &c->be->be_update_ndn ) ) { + ber_memfree_x( c->be->be_update_ndn.bv_val, NULL ); } + c->be->be_update_ndn = c->value_ndn; + BER_BVZERO( &c->value_dn ); + BER_BVZERO( &c->value_ndn ); SLAP_DBFLAGS(c->be) |= (SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SLURP_SHADOW); return(0); -- 2.39.5