From: Howard Chu Date: Tue, 6 Sep 2011 00:43:15 +0000 (-0700) Subject: Add AttributeDescription counter X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f8dc749c2de49ff85941271bd73655318f7d40e6;p=openldap Add AttributeDescription counter --- diff --git a/servers/slapd/ad.c b/servers/slapd/ad.c index 6c4bc4929d..2dc2500173 100644 --- a/servers/slapd/ad.c +++ b/servers/slapd/ad.c @@ -74,6 +74,8 @@ static int option_count = 1; static int msad_range_hack = 0; +static int ad_count; + static Attr_option *ad_find_option_definition( const char *opt, int optlen ); int ad_keystring( @@ -382,6 +384,9 @@ done:; d2->ad_flags = desc.ad_flags; d2->ad_cname.bv_len = desc.ad_type->sat_cname.bv_len; d2->ad_tags.bv_len = desc.ad_tags.bv_len; + ldap_pvt_thread_mutex_lock( &ad_index_mutex ); + d2->ad_index = ++ad_count; + ldap_pvt_thread_mutex_unlock( &ad_index_mutex ); if (dlen == 0) { d2->ad_cname.bv_val = d2->ad_type->sat_cname.bv_val; @@ -770,6 +775,7 @@ int slap_bv2undef_ad( /* shouldn't we protect this for concurrency? */ desc->ad_type = at; + desc->ad_index = 0; ldap_pvt_thread_mutex_lock( &ad_undef_mutex ); desc->ad_next = desc->ad_type->sat_ad; desc->ad_type->sat_ad = desc; diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index b075a53d65..ac2a295ab9 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -2071,6 +2071,7 @@ LDAP_SLAPD_V (ldap_pvt_thread_mutex_t) entry2str_mutex; #define gmtime_mutex ldap_int_gmtime_mutex #endif /* ! LDAP_DEVEL */ +LDAP_SLAPD_V (ldap_pvt_thread_mutex_t) ad_index_mutex; LDAP_SLAPD_V (ldap_pvt_thread_mutex_t) ad_undef_mutex; LDAP_SLAPD_V (ldap_pvt_thread_mutex_t) oc_undef_mutex; diff --git a/servers/slapd/schema_init.c b/servers/slapd/schema_init.c index 67508fc70d..da2274c1b6 100644 --- a/servers/slapd/schema_init.c +++ b/servers/slapd/schema_init.c @@ -164,6 +164,7 @@ unsigned int index_intlen = SLAP_INDEX_INTLEN_DEFAULT; unsigned int index_intlen_strlen = SLAP_INDEX_INTLEN_STRLEN( SLAP_INDEX_INTLEN_DEFAULT ); +ldap_pvt_thread_mutex_t ad_index_mutex; ldap_pvt_thread_mutex_t ad_undef_mutex; ldap_pvt_thread_mutex_t oc_undef_mutex; @@ -6844,6 +6845,7 @@ schema_destroy( void ) syn_destroy(); if( schema_init_done ) { + ldap_pvt_thread_mutex_destroy( &ad_index_mutex ); ldap_pvt_thread_mutex_destroy( &ad_undef_mutex ); ldap_pvt_thread_mutex_destroy( &oc_undef_mutex ); } diff --git a/servers/slapd/schema_prep.c b/servers/slapd/schema_prep.c index dc5627fae2..85cd15c143 100644 --- a/servers/slapd/schema_prep.c +++ b/servers/slapd/schema_prep.c @@ -1161,6 +1161,7 @@ slap_schema_load( void ) slap_at_proxied.sat_syntax = slap_schema.si_syn_octetString; slap_schema.si_at_proxied = &slap_at_proxied; + ldap_pvt_thread_mutex_init( &ad_index_mutex ); ldap_pvt_thread_mutex_init( &ad_undef_mutex ); ldap_pvt_thread_mutex_init( &oc_undef_mutex ); diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 685ec520ce..66df1cff29 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -851,6 +851,7 @@ struct AttributeDescription { #define SLAP_DESC_BINARY 0x01U #define SLAP_DESC_TAG_RANGE 0x80U #define SLAP_DESC_TEMPORARY 0x1000U + unsigned ad_index; }; /* flags to slap_*2undef_ad to register undefined (0, the default)