Add AttributeDescription counter

This commit is contained in:
Howard Chu 2011-09-05 17:43:15 -07:00
parent e071488c85
commit f8dc749c2d
5 changed files with 11 additions and 0 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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 );
}

View File

@ -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 );

View File

@ -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)