From: Howard Chu Date: Sat, 22 Jan 2005 20:18:38 +0000 (+0000) Subject: Schema caching for slaptools X-Git-Tag: OPENLDAP_REL_ENG_2_3_BP~280 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=47e7948007688ff19ed209a7f6fbb7b07f078135;p=openldap Schema caching for slaptools --- diff --git a/servers/slapd/at.c b/servers/slapd/at.c index 58c40006bd..7958a1ec39 100644 --- a/servers/slapd/at.c +++ b/servers/slapd/at.c @@ -57,9 +57,12 @@ struct aindexrec { }; static Avlnode *attr_index = NULL; +static Avlnode *attr_cache = NULL; static LDAP_SLIST_HEAD(ATList, slap_attribute_type) attr_list = LDAP_SLIST_HEAD_INITIALIZER(&attr_list); +int at_oc_cache; + static int attr_index_cmp( const void *v_air1, @@ -100,8 +103,18 @@ at_bvfind( struct berval *name ) { struct aindexrec *air; + if ( attr_cache ) { + air = avl_find( attr_cache, name, attr_index_name_cmp ); + if ( air ) return air->air_at; + } + air = avl_find( attr_index, name, attr_index_name_cmp ); + if ( air && ( slapMode & SLAP_TOOL_MODE ) && at_oc_cache ) { + avl_insert( &attr_cache, (caddr_t) air, + attr_index_cmp, avl_dup_error ); + } + return air != NULL ? air->air_at : NULL; } diff --git a/servers/slapd/attr.c b/servers/slapd/attr.c index 8908a65da9..ee0f46daab 100644 --- a/servers/slapd/attr.c +++ b/servers/slapd/attr.c @@ -177,7 +177,7 @@ attr_merge( Attribute **a; for ( a = &e->e_attrs; *a != NULL; a = &(*a)->a_next ) { - if ( ad_cmp( (*a)->a_desc, desc ) == 0 ) { + if ( (*a)->a_desc == desc ) { break; } } @@ -261,7 +261,7 @@ attr_merge_one( Attribute **a; for ( a = &e->e_attrs; *a != NULL; a = &(*a)->a_next ) { - if ( ad_cmp( (*a)->a_desc, desc ) == 0 ) { + if ( (*a)->a_desc == desc ) { break; } } @@ -353,7 +353,7 @@ attr_find( AttributeDescription *desc ) { for ( ; a != NULL; a = a->a_next ) { - if ( ad_cmp( a->a_desc, desc ) == 0 ) { + if ( a->a_desc == desc ) { return( a ); } } @@ -376,7 +376,7 @@ attr_delete( Attribute **a; for ( a = attrs; *a != NULL; a = &(*a)->a_next ) { - if ( ad_cmp( (*a)->a_desc, desc ) == 0 ) { + if ( (*a)->a_desc == desc ) { Attribute *save = *a; *a = (*a)->a_next; attr_free( save ); diff --git a/servers/slapd/oc.c b/servers/slapd/oc.c index b7ac0ba4e0..4afb1e1751 100644 --- a/servers/slapd/oc.c +++ b/servers/slapd/oc.c @@ -119,6 +119,7 @@ struct oindexrec { }; static Avlnode *oc_index = NULL; +static Avlnode *oc_cache = NULL; static LDAP_SLIST_HEAD(OCList, slap_object_class) oc_list = LDAP_SLIST_HEAD_INITIALIZER(&oc_list); @@ -161,9 +162,17 @@ oc_bvfind( struct berval *ocname ) { struct oindexrec *oir; + if ( oc_cache ) { + oir = avl_find( oc_cache, ocname, oc_index_name_cmp ); + if ( oir ) return oir->oir_oc; + } oir = avl_find( oc_index, ocname, oc_index_name_cmp ); if ( oir != NULL ) { + if ( at_oc_cache ) { + avl_insert( &oc_cache, (caddr_t) oir, + oc_index_cmp, avl_dup_error ); + } return( oir->oir_oc ); } diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 2f91d7928f..f491e7f9ab 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -144,6 +144,7 @@ LDAP_SLAPD_F (int) slap_entry2mods LDAP_P(( Entry *e, /* * at.c */ +LDAP_SLAPD_V(int) at_oc_cache; LDAP_SLAPD_F (void) at_config LDAP_P(( const char *fname, int lineno, int argc, char **argv )); diff --git a/servers/slapd/slapcommon.c b/servers/slapd/slapcommon.c index bafe34dafe..1812ede6e3 100644 --- a/servers/slapd/slapcommon.c +++ b/servers/slapd/slapcommon.c @@ -337,6 +337,7 @@ slap_tool_init( exit( EXIT_FAILURE ); } + at_oc_cache = 1; ldap_syslog = 0; switch ( tool ) {