From: Howard Chu Date: Wed, 14 Sep 2005 06:17:59 +0000 (+0000) Subject: Change slap_ad_undef_remove() to slap_ad_undef_promote(). X-Git-Tag: OPENLDAP_REL_ENG_2_2_MP~430 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=9b1d798ad2ef1f586c0f390ee65988ff5d568418;p=openldap Change slap_ad_undef_remove() to slap_ad_undef_promote(). AttributeDescriptions must never be freed in a running slapd. --- diff --git a/servers/slapd/ad.c b/servers/slapd/ad.c index 2b32e533c7..676cf8d86f 100644 --- a/servers/slapd/ad.c +++ b/servers/slapd/ad.c @@ -770,11 +770,15 @@ int slap_bv2undef_ad( } static int -undef_remove( +undef_promote( AttributeType *at, - char *name ) + char *name, + AttributeType *nat ) { - AttributeDescription **u_ad; + AttributeDescription **u_ad, **n_ad; + + /* Get to last ad on the new type */ + for ( n_ad = &nat->sat_ad; *n_ad; n_ad = &(*n_ad)->ad_next ) ; for ( u_ad = &at->sat_ad; *u_ad; ) { struct berval bv; @@ -791,8 +795,9 @@ undef_remove( *u_ad = (*u_ad)->ad_next; - ch_free( tmp ); - + tmp->ad_next = NULL; + *n_ad = tmp; + n_ad = &tmp->ad_next; } else { u_ad = &(*u_ad)->ad_next; } @@ -802,16 +807,17 @@ undef_remove( } int -slap_ad_undef_remove( - char *name ) +slap_ad_undef_promote( + char *name, + AttributeType *at ) { int rc; ldap_pvt_thread_mutex_lock( &ad_undef_mutex ); - rc = undef_remove( slap_schema.si_at_undefined, name ); + rc = undef_promote( slap_schema.si_at_undefined, name, at ); if ( rc == 0 ) { - rc = undef_remove( slap_schema.si_at_proxied, name ); + rc = undef_promote( slap_schema.si_at_proxied, name, at ); } ldap_pvt_thread_mutex_unlock( &ad_undef_mutex ); diff --git a/servers/slapd/at.c b/servers/slapd/at.c index 1b3b7b5991..59bdb98142 100644 --- a/servers/slapd/at.c +++ b/servers/slapd/at.c @@ -405,13 +405,13 @@ at_insert( } if ( sat->sat_oid ) { - slap_ad_undef_remove( sat->sat_oid ); + slap_ad_undef_promote( sat->sat_oid, sat ); } names = sat->sat_names; if ( names ) { while ( *names ) { - slap_ad_undef_remove( *names ); + slap_ad_undef_promote( *names, sat ); names++; } } diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index f901a6a379..5261751f7f 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -168,8 +168,9 @@ LDAP_SLAPD_F (int) slap_bv2undef_ad LDAP_P(( const char **text, unsigned proxied )); -LDAP_SLAPD_F (int) slap_ad_undef_remove LDAP_P(( - char *name )); +LDAP_SLAPD_F (int) slap_ad_undef_promote LDAP_P(( + char *name, + AttributeType *nat )); LDAP_SLAPD_F (AttributeDescription *) ad_find_tags LDAP_P(( AttributeType *type,