]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/at.c
ITS#3549 cleanup abandon/cancel processing
[openldap] / servers / slapd / at.c
index 740a2b7ef58d355c5f2f97f5d8dd151cbe59fb78..7958a1ec3987b154c4916f71742ddcd80ab56656 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -24,7 +24,6 @@
 #include <ac/string.h>
 #include <ac/time.h>
 
-#include "ldap_pvt.h"
 #include "slap.h"
 
 
@@ -58,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,
@@ -101,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;
 }