]> git.sur5r.net Git - openldap/commitdiff
Change AttributeName.an_oc_exclude to an_oc_flags, avoid multiple
authorQuanah Gibson-Mount <quanah@openldap.org>
Mon, 27 Jul 2009 22:19:18 +0000 (22:19 +0000)
committerQuanah Gibson-Mount <quanah@openldap.org>
Mon, 27 Jul 2009 22:19:18 +0000 (22:19 +0000)
futile searches for OC matches.  Perf improvement.

servers/slapd/aclparse.c
servers/slapd/ad.c
servers/slapd/controls.c
servers/slapd/overlays/pcache.c
servers/slapd/search.c
servers/slapd/slap.h
servers/slapd/slapi/slapi_pblock.c

index 3f0e3817228ae1c2b5955c592693aa0eac31fb4a..9a405660d7ac460b4737aaf9d58cfc801f50a357 100644 (file)
@@ -2774,7 +2774,7 @@ acl_unparse( AccessControl *a, struct berval *bv )
                for ( an = a->acl_attrs; an && !BER_BVISNULL( &an->an_name ); an++ ) {
                        if ( ! first ) *ptr++ = ',';
                        if (an->an_oc) {
-                               *ptr++ = an->an_oc_exclude ? '!' : '@';
+                               *ptr++ = ( an->an_flags & SLAP_AN_OCEXCLUDE ) ? '!' : '@';
                                ptr = lutil_strcopy( ptr, an->an_oc->soc_cname.bv_val );
 
                        } else {
index c881612799f6492f5782efa83204fb7df14e71ed..4c118c4313f84803fdba2ab68ac6f3aba226976f 100644 (file)
@@ -594,29 +594,33 @@ int ad_inlist(
                 * else if requested description is !objectClass, return
                 * attributes which the class does not require/allow
                 */
-               oc = attrs->an_oc;
-               if( oc == NULL && attrs->an_name.bv_val ) {
-                       switch( attrs->an_name.bv_val[0] ) {
-                       case '@': /* @objectClass */
-                       case '+': /* +objectClass (deprecated) */
-                       case '!': { /* exclude */
-                                       struct berval ocname;
-                                       ocname.bv_len = attrs->an_name.bv_len - 1;
-                                       ocname.bv_val = &attrs->an_name.bv_val[1];
-                                       oc = oc_bvfind( &ocname );
-                                       attrs->an_oc_exclude = 0;
-                                       if ( oc && attrs->an_name.bv_val[0] == '!' ) {
-                                               attrs->an_oc_exclude = 1;
-                                       }
-                               } break;
+               if ( !( attrs->an_flags & SLAP_AN_OCINITED )) {
+                       if( attrs->an_name.bv_val ) {
+                               switch( attrs->an_name.bv_val[0] ) {
+                               case '@': /* @objectClass */
+                               case '+': /* +objectClass (deprecated) */
+                               case '!': { /* exclude */
+                                               struct berval ocname;
+                                               ocname.bv_len = attrs->an_name.bv_len - 1;
+                                               ocname.bv_val = &attrs->an_name.bv_val[1];
+                                               oc = oc_bvfind( &ocname );
+                                               if ( oc && attrs->an_name.bv_val[0] == '!' ) {
+                                                       attrs->an_flags |= SLAP_AN_OCEXCLUDE;
+                                               } else {
+                                                       attrs->an_flags &= ~SLAP_AN_OCEXCLUDE;
+                                               }
+                                       } break;
 
-                       default: /* old (deprecated) way */
-                               oc = oc_bvfind( &attrs->an_name );
+                               default: /* old (deprecated) way */
+                                       oc = oc_bvfind( &attrs->an_name );
+                               }
+                               attrs->an_oc = oc;
                        }
-                       attrs->an_oc = oc;
+                       attrs->an_flags |= SLAP_AN_OCINITED;
                }
+               oc = attrs->an_oc;
                if( oc != NULL ) {
-                       if ( attrs->an_oc_exclude ) {
+                       if ( attrs->an_flags & SLAP_AN_OCEXCLUDE ) {
                                if ( oc == slap_schema.si_oc_extensibleObject ) {
                                        /* extensibleObject allows the return of anything */
                                        return 0;
@@ -932,7 +936,7 @@ str2anlist( AttributeName *an, char *in, const char *brkstr )
 
                anew->an_desc = NULL;
                anew->an_oc = NULL;
-               anew->an_oc_exclude = 0;
+               anew->an_flags = 0;
                ber_str2bv(s, 0, 1, &anew->an_name);
                slap_bv2ad(&anew->an_name, &anew->an_desc, &text);
                if ( !anew->an_desc ) {
@@ -959,7 +963,7 @@ str2anlist( AttributeName *an, char *in, const char *brkstr )
                                        }
 
                                        if ( anew->an_name.bv_val[0] == '!' ) {
-                                               anew->an_oc_exclude = 1;
+                                               anew->an_flags |= SLAP_AN_OCEXCLUDE;
                                        }
                                } break;
 
@@ -971,6 +975,7 @@ str2anlist( AttributeName *an, char *in, const char *brkstr )
                                }
                        }
                }
+               anew->an_flags |= SLAP_AN_OCINITED;
                anew++;
        }
 
index 93476070d1a8b3a86e03933ef59d78cedca8d0ca..d20dbd30ae3c31c44cb2221da59ebbf7bd57f0cb 100644 (file)
@@ -1414,7 +1414,7 @@ parseReadAttrs(
 
                an[i].an_desc = NULL;
                an[i].an_oc = NULL;
-               an[i].an_oc_exclude = 0;
+               an[i].an_flags = 0;
                rc = slap_bv2ad( &an[i].an_name, &an[i].an_desc, &dummy );
                if ( rc == LDAP_SUCCESS ) {
                        an[i].an_name = an[i].an_desc->ad_cname;
index 80a5d74028e716342ccb375e56d0b8a492e3e529..3a1a5fa60b0732f46adc6bcc7659b0f40de63ced 100644 (file)
@@ -1605,7 +1605,7 @@ filter2template(
                (*filter_attrs)[*filter_cnt].an_desc = ad;
                (*filter_attrs)[*filter_cnt].an_name = ad->ad_cname;
                (*filter_attrs)[*filter_cnt].an_oc = NULL;
-               (*filter_attrs)[*filter_cnt].an_oc_exclude = 0;
+               (*filter_attrs)[*filter_cnt].an_flags = 0;
                BER_BVZERO( &(*filter_attrs)[*filter_cnt+1].an_name );
                (*filter_cnt)++;
                if ( ad == slap_schema.si_ad_objectClass )
@@ -2202,14 +2202,14 @@ add_filter_attrs(
                (*new_attrs)[j].an_name = filter_attrs[i].an_name;
                (*new_attrs)[j].an_desc = filter_attrs[i].an_desc;
                (*new_attrs)[j].an_oc = NULL;
-               (*new_attrs)[j].an_oc_exclude = 0;
+               (*new_attrs)[j].an_flags = 0;
                j++;
        }
        if ( addoc ) {
                (*new_attrs)[j].an_name = slap_schema.si_ad_objectClass->ad_cname;
                (*new_attrs)[j].an_desc = slap_schema.si_ad_objectClass;
                (*new_attrs)[j].an_oc = NULL;
-               (*new_attrs)[j].an_oc_exclude = 0;
+               (*new_attrs)[j].an_flags = 0;
                j++;
        }
        BER_BVZERO( &(*new_attrs)[j].an_name );
@@ -3039,7 +3039,7 @@ pc_cf_gen( ConfigArgs *c )
                                        attr_name->an_name = attr_name->an_desc->ad_cname;
                                }
                                attr_name->an_oc = NULL;
-                               attr_name->an_oc_exclude = 0;
+                               attr_name->an_flags = 0;
                                if ( attr_name->an_desc == slap_schema.si_ad_objectClass )
                                        qm->attr_sets[num].flags |= PC_GOT_OC;
                                attr_name++;
index be0b283f82df49cb037018088e047ecc8640dc45..ecdae3ce6154d32526cbf4d45a03205e96753b70 100644 (file)
@@ -152,7 +152,7 @@ do_search(
                const char *dummy;      /* ignore msgs from bv2ad */
                op->ors_attrs[i].an_desc = NULL;
                op->ors_attrs[i].an_oc = NULL;
-               op->ors_attrs[i].an_oc_exclude = 0;
+               op->ors_attrs[i].an_flags = 0;
                if ( slap_bv2ad( &op->ors_attrs[i].an_name,
                        &op->ors_attrs[i].an_desc, &dummy ) != LDAP_SUCCESS )
                {
index 3fb72f03701b3ea83e6f44954080558bc2f756e9..7eb3908dcbd7f63342a8efeb85721f174c205363 100644 (file)
@@ -842,10 +842,13 @@ struct AttributeDescription {
 #define SLAP_AD_PROXIED                0x01U
 #define        SLAP_AD_NOINSERT        0x02U
 
+#define        SLAP_AN_OCEXCLUDE       0x01
+#define        SLAP_AN_OCINITED        0x02
+
 struct AttributeName {
        struct berval           an_name;
        AttributeDescription    *an_desc;
-       int                     an_oc_exclude;
+       int                     an_flags;
        ObjectClass             *an_oc;
 };
 
index bdff8eba3f49b2e4b006dc507cf55e9295eebe91..28615bbd3670fed86dc8f1a5001158c24b631c80 100644 (file)
@@ -1152,7 +1152,7 @@ pblock_set( Slapi_PBlock *pb, int param, void *value )
                        for ( i = 0; attrs[i] != NULL; i++ ) {
                                an[j].an_desc = NULL;
                                an[j].an_oc = NULL;
-                               an[j].an_oc_exclude = 0;
+                               an[j].an_flags = 0;
                                an[j].an_name.bv_val = attrs[i];
                                an[j].an_name.bv_len = strlen( attrs[i] );
                                if ( slap_bv2ad( &an[j].an_name, &an[j].an_desc, &pb->pb_rs->sr_text ) == LDAP_SUCCESS ) {