]> git.sur5r.net Git - openldap/commitdiff
mutex-protect "undefined" attribute descriptions/objectClasses addition (ITS#3958)
authorPierangelo Masarati <ando@openldap.org>
Mon, 22 Aug 2005 09:46:17 +0000 (09:46 +0000)
committerPierangelo Masarati <ando@openldap.org>
Mon, 22 Aug 2005 09:46:17 +0000 (09:46 +0000)
servers/slapd/ad.c
servers/slapd/oc.c
servers/slapd/proto-slap.h
servers/slapd/schema_init.c
servers/slapd/schema_prep.c

index 38bda68141f8f6e4ec0ee1ee4a4158ebf6945500..1eec4b1f9d8cde38f67ffdadf891e79e717ed98b 100644 (file)
@@ -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 ) {
index 6af4cbcbcc9e11c6ef645287f01e9e35789ced33..2772d72711fb99387701221a70809497753c91c4 100644 (file)
@@ -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;
 }
index f98de6a8959538083477795b29b442f7d626df27..f359298df935f45bc4bab4626bb7d93aa026f331 100644 (file)
@@ -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;
index 183d1875bfa45a3dcd3e7a546c402d6bde881c52..5ff82c99749524f389a799e6a0b9cd6f42a12d79 100644 (file)
@@ -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 );
 }
index 03bca79b8b43f8fbef6b087187e8a1457c63340e..dc2964e351b95b7ee5e3b96e6cf3b9b4df15795e 100644 (file)
@@ -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;
 }