From de90dbbc52d34e1430f689d730e6bca126360518 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Mon, 22 Aug 2005 09:46:17 +0000 Subject: [PATCH] mutex-protect "undefined" attribute descriptions/objectClasses addition (ITS#3958) --- servers/slapd/ad.c | 5 ++++- servers/slapd/oc.c | 2 ++ servers/slapd/proto-slap.h | 3 +++ servers/slapd/schema_init.c | 6 ++++++ servers/slapd/schema_prep.c | 9 ++++++--- 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/servers/slapd/ad.c b/servers/slapd/ad.c index 38bda68141..1eec4b1f9d 100644 --- a/servers/slapd/ad.c +++ b/servers/slapd/ad.c @@ -737,9 +737,12 @@ int slap_bv2undef_ad( /* canonical to upper case */ ldap_pvt_str2upper( desc->ad_cname.bv_val ); - desc->ad_type = slap_schema.si_at_undefined; + /* shouldn't we protect this for concurrency? */ + desc->ad_type = at; + ldap_pvt_thread_mutex_lock( &ad_undef_mutex ); desc->ad_next = desc->ad_type->sat_ad; desc->ad_type->sat_ad = desc; + ldap_pvt_thread_mutex_unlock( &ad_undef_mutex ); } if( !*ad ) { diff --git a/servers/slapd/oc.c b/servers/slapd/oc.c index 6af4cbcbcc..2772d72711 100644 --- a/servers/slapd/oc.c +++ b/servers/slapd/oc.c @@ -227,7 +227,9 @@ oc_bvfind_undef( struct berval *ocname ) AC_MEMCPY( oc->soc_cname.bv_val, ocname->bv_val, ocname->bv_len ); LDAP_STAILQ_NEXT( oc, soc_next ) = NULL; + ldap_pvt_thread_mutex_lock( &oc_undef_mutex ); LDAP_STAILQ_INSERT_HEAD( &oc_undef_list, oc, soc_next ); + ldap_pvt_thread_mutex_unlock( &oc_undef_mutex ); return oc; } diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index f98de6a895..f359298df9 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -1704,6 +1704,9 @@ LDAP_SLAPD_V (ldap_pvt_thread_mutex_t) replog_mutex; LDAP_SLAPD_V (ldap_pvt_thread_mutex_t) gmtime_mutex; #endif +LDAP_SLAPD_V (ldap_pvt_thread_mutex_t) ad_undef_mutex; +LDAP_SLAPD_V (ldap_pvt_thread_mutex_t) oc_undef_mutex; + LDAP_SLAPD_V (ber_socket_t) dtblsize; LDAP_SLAPD_V (int) use_reverse_lookup; diff --git a/servers/slapd/schema_init.c b/servers/slapd/schema_init.c index 183d1875bf..5ff82c9974 100644 --- a/servers/slapd/schema_init.c +++ b/servers/slapd/schema_init.c @@ -79,6 +79,9 @@ unsigned int index_substr_if_maxlen = SLAP_INDEX_SUBSTR_IF_MAXLEN_DEFAULT; unsigned int index_substr_any_len = SLAP_INDEX_SUBSTR_ANY_LEN_DEFAULT; unsigned int index_substr_any_step = SLAP_INDEX_SUBSTR_ANY_STEP_DEFAULT; +ldap_pvt_thread_mutex_t ad_undef_mutex; +ldap_pvt_thread_mutex_t oc_undef_mutex; + static int inValidate( Syntax *syntax, @@ -3966,4 +3969,7 @@ schema_destroy( void ) mr_destroy(); mru_destroy(); syn_destroy(); + + 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 03bca79b8b..dc2964e351 100644 --- a/servers/slapd/schema_prep.c +++ b/servers/slapd/schema_prep.c @@ -1143,6 +1143,12 @@ slap_schema_load( void ) } } + slap_at_undefined.sat_syntax = slap_schema.si_syn_octetString; + slap_schema.si_at_undefined = &slap_at_undefined; + + ldap_pvt_thread_mutex_init( &ad_undef_mutex ); + ldap_pvt_thread_mutex_init( &oc_undef_mutex ); + for( i=0; ad_map[i].ssam_name; i++ ) { assert( ad_map[i].ssam_defn != NULL ); { @@ -1313,9 +1319,6 @@ slap_schema_load( void ) } } - slap_at_undefined.sat_syntax = slap_schema.si_syn_octetString; - slap_schema.si_at_undefined = &slap_at_undefined; - return LDAP_SUCCESS; } -- 2.39.5