Commit 47e79480 authored by Howard Chu's avatar Howard Chu
Browse files

Schema caching for slaptools

parent ae0f47b0
......@@ -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;
}
......
......@@ -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 );
......
......@@ -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 );
}
......
......@@ -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 ));
......
......@@ -337,6 +337,7 @@ slap_tool_init(
exit( EXIT_FAILURE );
}
at_oc_cache = 1;
ldap_syslog = 0;
switch ( tool ) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment