]> git.sur5r.net Git - openldap/commitdiff
Moved proxy caching to overlay
authorHoward Chu <hyc@openldap.org>
Sat, 6 Dec 2003 11:12:53 +0000 (11:12 +0000)
committerHoward Chu <hyc@openldap.org>
Sat, 6 Dec 2003 11:12:53 +0000 (11:12 +0000)
13 files changed:
servers/slapd/back-meta/Makefile.in
servers/slapd/back-meta/back-meta.h
servers/slapd/back-meta/cache-config.c [deleted file]
servers/slapd/back-meta/cache-merge.c [deleted file]
servers/slapd/back-meta/cache-query.c [deleted file]
servers/slapd/back-meta/cache-remove.c [deleted file]
servers/slapd/back-meta/cache-search.c [deleted file]
servers/slapd/back-meta/cache-substring.c [deleted file]
servers/slapd/back-meta/cache-template.c [deleted file]
servers/slapd/back-meta/cache.h [deleted file]
servers/slapd/back-meta/config.c
servers/slapd/back-meta/init.c
servers/slapd/back-meta/search.c

index f67872d79d441b16ef9157ef86900fb01218eacd..5d98a928293347a647ba513fcd651146c323ccdf 100644 (file)
 ## <http://www.OpenLDAP.org/license.html>.
 
 SRCS   = init.c config.c search.c bind.c unbind.c add.c compare.c \
-               cache-query.c cache-search.c cache-config.c cache-merge.c \
-               cache-template.c cache-substring.c cache-remove.c \
                delete.c modify.c modrdn.c \
                conn.c candidates.c dncache.c
 OBJS   = init.lo config.lo search.lo bind.lo unbind.lo add.lo compare.lo \
-               cache-query.lo cache-search.lo cache-config.lo cache-merge.lo \
-               cache-template.lo cache-substring.lo cache-remove.lo \
                delete.lo modify.lo modrdn.lo \
                conn.lo candidates.lo dncache.lo
 
index cfa95ea1f7b2f291245f14fe1bbc2377611eac0a..e6d6464080153480a3e381875c3434ca312164f7 100644 (file)
@@ -94,7 +94,6 @@
 
 /* String rewrite library */
 #include "rewrite.h"
-#include "cache.h"
 LDAP_BEGIN_DECL
 
 struct slap_conn;
@@ -168,7 +167,6 @@ struct metainfo {
        struct metatarget       **targets;
 
        struct rewrite_info     *rwinfo;
-       cache_manager           *cm; 
        Backend                 *glue_be; 
 
        struct metadncache      cache;
diff --git a/servers/slapd/back-meta/cache-config.c b/servers/slapd/back-meta/cache-config.c
deleted file mode 100644 (file)
index 1fb7e10..0000000
+++ /dev/null
@@ -1,333 +0,0 @@
-/* $OpenLDAP$ */
-/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
- *
- * Copyright 1999-2003 The OpenLDAP Foundation.
- * Portions Copyright 2003 IBM Corporation.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted only as authorized by the OpenLDAP
- * Public License.
- *
- * A copy of this license is available in the file LICENSE in the
- * top-level directory of the distribution or, alternatively, at
- * <http://www.OpenLDAP.org/license.html>.
- */
-/* ACKNOWLEDGEMENTS:
- * This work was initially developed by the Apurva Kumar for inclusion
- * in OpenLDAP Software.
- */
-
-#include "portable.h"
-
-#include <stdio.h>
-
-#include <ac/string.h>
-#include <ac/socket.h>
-
-#include "slap.h"
-#include "../back-ldap/back-ldap.h"
-#include "back-meta.h"
-
-#define MAX_ATTR_SETS 500 
-static void find_supersets( struct attr_set* attr_sets, int numsets ); 
-static int compare_sets( struct attr_set* setA, int, int );
-
-int
-meta_back_cache_config(
-       BackendDB       *be,
-       const char      *fname,
-       int             lineno,
-       int             argc,
-       char            **argv
-)
-{
-       struct metainfo *li = ( struct metainfo * )be->be_private;
-
-       cache_manager*  cm = li->cm; 
-       query_manager*  qm = cm->qm;
-       QueryTemplate*  temp;
-       AttributeName*  attr_name; 
-       AttributeName*  attrs;
-       AttributeName*  attrarray;
-       const char*     text=NULL; 
-
-       int             index, i; 
-       int             num; 
-
-       if ( li == NULL ) {
-               fprintf( stderr, "%s: line %d: meta backend info is null!\n",
-                               fname, lineno );
-               return 1;
-       }
-
-       if ( strcasecmp( argv[0], "cacheparams" ) == 0 ) {
-               struct berval cache_suffix; 
-
-               if ( argc < 6 ) {
-                       fprintf( stderr, "%s: line %d: missing arguments in \"cacheparams"
-                               " <thresh_lo> <thresh_hi> <numattrsets> <entry limit> "
-                               "<cycle_time>\" \n", fname, lineno );
-                       return( 1 );
-               }
-
-               cm->caching = 1;  
-               cm->thresh_lo = atoi( argv[1] );
-               cm->thresh_hi = atoi( argv[2] );
-               if ( cm->thresh_hi <= cm->thresh_lo ) {
-                       fprintf( stderr, "%s: line %d: <thresh_lo> must be < <thresh_hi> "
-                               "in \"cacheparams <thresh_lo> <thresh_hi> <numattrsets> "
-                               "<entry limit> <cycle_time>\" \n", fname, lineno );
-                       return( 1 );
-               }
-
-               cm->numattrsets = atoi( argv[3] );
-               if ( cm->numattrsets > MAX_ATTR_SETS ) {
-                       fprintf( stderr, "%s: line %d: <numattrsets> must be <= %d in "
-                               "\"cacheparams <thresh_lo> <thresh_hi> <numattrsets> "
-                               "<entry limit> <cycle_time>\" \n",
-                               fname, lineno, MAX_ATTR_SETS );
-                       return( 1 );
-               }
-
-               cm->num_entries_limit = atoi( argv[4] ); 
-               cm->cc_period = atoi( argv[5] ); 
-#ifdef NEW_LOGGING
-               LDAP_LOG( BACK_META, DETAIL1,
-                               "Total # of attribute sets to be cached = %d\n",
-                               cm->numattrsets, 0, 0 ); 
-#else
-               Debug( LDAP_DEBUG_ANY,
-                               "Total # of attribute sets to be cached = %d\n",
-                               cm->numattrsets, 0, 0 ); 
-#endif
-               qm->attr_sets = ( struct attr_set * )malloc( cm->numattrsets *
-                                               sizeof( struct attr_set ));
-               for ( i = 0; i < cm->numattrsets; i++ ) {
-                       qm->attr_sets[i].attrs = NULL; 
-               }
-               rewrite_session( li->rwinfo, "cacheBase", be->be_nsuffix[0].bv_val,
-                                       0, &cache_suffix.bv_val );
-               if ( cache_suffix.bv_val != NULL ) {
-                       cache_suffix.bv_len = strlen( cache_suffix.bv_val );
-               } else {
-                       cache_suffix = be->be_nsuffix[0];
-               }
-               li->glue_be = select_backend( &cache_suffix, 0, 1 );
-               li->glue_be->be_flags |= SLAP_BFLAG_NO_SCHEMA_CHECK;
-               if ( cache_suffix.bv_val != be->be_nsuffix[0].bv_val ) {
-                       ch_free( cache_suffix.bv_val );
-               }
-
-       } else if ( strcasecmp( argv[0], "attrset" ) == 0 ) {
-               if ( argc < 3 ) {
-                       fprintf( stderr, "%s: line %d: missing arguments in \"attr-set "
-                               "<index> <attributes>\" line\n", fname, lineno );
-                       return( 1 );
-               }
-#ifdef NEW_LOGGING
-               LDAP_LOG( BACK_META, DETAIL1, "Attribute Set # %d\n",
-                               atoi( argv[1] ), 0, 0 ); 
-#else
-               Debug( LDAP_DEBUG_ANY, "Attribute Set # %d\n",
-                               atoi( argv[1] ), 0, 0 ); 
-#endif
-               if (atoi(argv[1]) >= cm->numattrsets) {
-                       fprintf( stderr, "%s; line %d index out of bounds \n",
-                                       fname, lineno );
-                       return 1; 
-               } 
-               index = atoi( argv[1] );
-               if ( argv[2] && ( strcmp( argv[2], "*" ) != 0 )) {
-                       for ( i = 2; argv[i] != NULL; i++ ) {
-#ifdef NEW_LOGGING
-                               LDAP_LOG( BACK_META, DETAIL1, "\t %s\n",
-                                               argv[i], 0, 0 );
-#else
-                               Debug( LDAP_DEBUG_ANY, "\t %s\n",
-                                               argv[i], 0, 0 );
-#endif
-                               attrs = qm->attr_sets[index].attrs;
-                               qm->attr_sets[index].attrs = (AttributeName*)realloc(
-                                               attrs, i * sizeof( AttributeName ));
-                               attr_name = qm->attr_sets[index].attrs + ( i - 2 ); 
-                               ber_str2bv( argv[i], strlen(argv[i]), 1,
-                                               &attr_name->an_name); 
-                               attr_name->an_desc = NULL; 
-                               slap_bv2ad( &attr_name->an_name,
-                                               &attr_name->an_desc, &text );
-                               attr_name++; 
-                               attr_name->an_name.bv_val = NULL; 
-                               attr_name->an_name.bv_len = 0; 
-                       }
-                       qm->attr_sets[index].count = i - 2; 
-               }
-       } else if ( strcasecmp( argv[0], "addtemplate" ) == 0 ) {
-               if ( argc != 4 ) {
-                       fprintf( stderr, "%s: line %d: missing argument(s) in "
-                               "\"addtemplate <filter> <proj attr set> <TTL>\" line\n",
-                               fname, lineno );
-                       return( 1 );
-               }
-               if (( i = atoi( argv[2] )) >= cm->numattrsets ) {
-#ifdef NEW_LOGGING
-                       LDAP_LOG( BACK_META, DETAIL1,
-                                       "%s: line %d, template index invalid\n",
-                                       fname, lineno, 0 );  
-#else
-                       Debug( LDAP_DEBUG_ANY,
-                                       "%s: line %d, template index invalid\n",
-                                       fname, lineno, 0 );  
-#endif
-                       return 1; 
-               }
-               num = cm->numtemplates; 
-               if ( num == 0 )
-                       find_supersets( qm->attr_sets, cm->numattrsets );
-               qm->templates = ( QueryTemplate* )realloc( qm->templates,
-                               ( num + 2 ) * sizeof( QueryTemplate ));
-               temp = qm->templates + num; 
-               ldap_pvt_thread_rdwr_init( &temp->t_rwlock ); 
-               temp->query = temp->query_last = NULL;
-               temp->ttl = atoi( argv[3] );
-               temp->no_of_queries = 0; 
-               if ( argv[1] == NULL ) {
-#ifdef NEW_LOGGING
-                       LDAP_LOG( BACK_META, DETAIL1,
-                                       "Templates string not specified "
-                                       "for template %d\n", num, 0, 0 ); 
-#else
-                       Debug( LDAP_DEBUG_ANY,
-                                       "Templates string not specified "
-                                       "for template %d\n", num, 0, 0 ); 
-#endif
-                       return 1; 
-               }
-               temp->querystr = ch_strdup( argv[1] );
-#ifdef NEW_LOGGING
-               LDAP_LOG( BACK_META, DETAIL1, "Template:\n", 0, 0, 0 );
-#else
-               Debug( LDAP_DEBUG_ANY, "Template:\n", 0, 0, 0 );
-#endif
-#ifdef NEW_LOGGING
-               LDAP_LOG( BACK_META, DETAIL1, "  query template: %s\n",
-                               temp->querystr, 0, 0 );
-#else
-               Debug( LDAP_DEBUG_ANY, "  query template: %s\n",
-                               temp->querystr, 0, 0 );
-#endif
-               temp->attr_set_index = i; 
-#ifdef NEW_LOGGING
-               LDAP_LOG( BACK_META, DETAIL1, "  attributes: \n", 0, 0, 0 );
-#else
-               Debug( LDAP_DEBUG_ANY, "  attributes: \n", 0, 0, 0 );
-#endif
-               if ( ( attrarray = qm->attr_sets[i].attrs ) != NULL ) {
-                       for ( i=0; attrarray[i].an_name.bv_val; i++ ) 
-#ifdef NEW_LOGGING
-                               LDAP_LOG( BACK_META, DETAIL1, "\t%s\n",
-                                       attrarray[i].an_name.bv_val, 0, 0 );
-#else
-                               Debug( LDAP_DEBUG_ANY, "\t%s\n",
-                                       attrarray[i].an_name.bv_val, 0, 0 );
-#endif
-               }
-               temp++;         
-               temp->querystr = NULL; 
-               cm->numtemplates++;
-       } 
-       /* anything else */
-       else {
-               fprintf( stderr, "%s: line %d: unknown directive \"%s\" in meta "
-                               "database definition (ignored)\n",
-                               fname, lineno, argv[0] );
-       }
-       return 0;
-}
-
-void
-find_supersets ( struct attr_set* attr_sets, int numsets )
-{
-       int num[MAX_ATTR_SETS];
-       int i, j, res;
-       int* id_array;
-       for ( i = 0; i < MAX_ATTR_SETS; i++ )
-               num[i] = 0;
-
-       for ( i = 0; i < numsets; i++ ) {
-               attr_sets[i].ID_array = (int*) malloc( sizeof( int ) );
-               attr_sets[i].ID_array[0] = -1; 
-       } 
-
-       for ( i = 0; i < numsets; i++ ) {
-               for ( j=i+1; j < numsets; j++ ) {
-                       res = compare_sets( attr_sets, i, j ); 
-                       switch ( res ) {
-                       case 0:
-                               break;
-                       case 3: 
-                       case 1: 
-                               id_array = attr_sets[i].ID_array; 
-                               attr_sets[i].ID_array = (int *) realloc( id_array,
-                                                       ( num[i] + 2 ) * sizeof( int )); 
-                               attr_sets[i].ID_array[num[i]] = j; 
-                               attr_sets[i].ID_array[num[i]+1] = -1; 
-                               num[i]++;
-                               if (res == 1) 
-                                       break;
-                       case 2: 
-                               id_array = attr_sets[j].ID_array; 
-                               attr_sets[j].ID_array = (int *) realloc( id_array,
-                                               ( num[j] + 2 ) * sizeof( int )); 
-                               attr_sets[j].ID_array[num[j]] = i; 
-                               attr_sets[j].ID_array[num[j]+1] = -1; 
-                               num[j]++;
-                               break;
-                       }
-               }
-       }
-}
-
-/* 
- * compares two sets of attributes (indices i and j) 
- * returns 0: if neither set is contained in the other set 
- *         1: if set i is contained in set j
- *         2: if set j is contained in set i
- *         3: the sets are equivalent 
- */
-
-int 
-compare_sets(struct attr_set* set, int i, int j)
-{
-       int k,l,numI,numJ;
-       int common=0;
-       int result=0;
-
-       if (( set[i].attrs == NULL ) && ( set[j].attrs == NULL ))
-               return 3;       
-
-       if ( set[i].attrs == NULL )
-               return 2; 
-
-       if ( set[j].attrs == NULL )
-               return 1; 
-   
-       numI = set[i].count; 
-       numJ = set[j].count; 
-
-       for ( l=0; l < numI; l++ ) {
-               for ( k = 0; k < numJ; k++ ) {
-                       if ( strcmp( set[i].attrs[l].an_name.bv_val,
-                                    set[j].attrs[k].an_name.bv_val ) == 0 )
-                               common++;       
-               }
-       }
-
-       if ( common == numI )
-               result = 1; 
-
-       if ( common == numJ )
-               result += 2;
-
-       return result; 
-}
diff --git a/servers/slapd/back-meta/cache-merge.c b/servers/slapd/back-meta/cache-merge.c
deleted file mode 100644 (file)
index e6cce64..0000000
+++ /dev/null
@@ -1,294 +0,0 @@
-/* $OpenLDAP$ */
-/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
- *
- * Copyright 1999-2003 The OpenLDAP Foundation.
- * Portions Copyright 2003 IBM Corporation.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted only as authorized by the OpenLDAP
- * Public License.
- *
- * A copy of this license is available in the file LICENSE in the
- * top-level directory of the distribution or, alternatively, at
- * <http://www.OpenLDAP.org/license.html>.
- */
-/* ACKNOWLEDGEMENTS:
- * This work was initially developed by the Apurva Kumar for inclusion
- * in OpenLDAP Software.
- */
-
-#include "portable.h"
-
-#include <stdio.h>
-
-#include <ac/socket.h>
-#include <ac/string.h>
-#include <ac/time.h>
-
-#include "slap.h"
-#include "ldif.h"
-#include "../back-ldap/back-ldap.h"
-#include "back-meta.h"
-#include "ldap_pvt.h"
-#undef ldap_debug      /* silence a warning in ldap-int.h */
-#include "ldap_log.h"
-#include "../../../libraries/libldap/ldap-int.h"
-#include <sys/time.h>
-
-static struct berval bv_queryid_any = BER_BVC( "(queryid=*)" );
-
-static Attribute* 
-add_attribute(AttributeDescription *ad,
-       Entry* e,
-       BerVarray value_array
-); 
-
-static int
-null_response (
-       Operation       *op,
-       SlapReply       *rs
-); 
-
-static int 
-normalize_values( Attribute* attr );   
-
-struct entry_info {
-       int                     size_init; 
-       int                     size_final; 
-       int                     added; 
-       Entry*                  entry; 
-       struct berval*          uuid; 
-       struct timeval          tv;     /* time */ 
-       enum type_of_result     err; 
-       Backend*                glue_be; 
-}; 
-
-
-int 
-get_entry_size(
-       Entry* e, 
-       int size_init, 
-       struct exception* result )
-{
-       Attribute       *a;
-        struct berval   bv;
-       int             i; 
-       int             tmplen;
-       int             size=0;
-
-       if ( result )
-               result->type = SUCCESS; 
-
-       if ( e->e_dn != NULL ) {
-               tmplen = strlen( e->e_dn );
-               size = LDIF_SIZE_NEEDED( 2, tmplen );
-       }
-
-       for ( a = e->e_attrs; a != NULL; a = a->a_next ) {
-               for ( i = 0; a->a_vals[i].bv_val != NULL; i++ ) {
-                       bv = a->a_vals[i];
-                       tmplen = a->a_desc->ad_cname.bv_len;
-                       size += LDIF_SIZE_NEEDED( tmplen, bv.bv_len);
-               }
-       }
-       if ((size < size_init) && result) {
-               result->type = SIZE_ERR; 
-       }
-       return size;
-}
-
-int
-merge_entry(
-       Operation               *op,
-       SlapReply               *rs,
-       struct berval*          query_uuid, 
-       struct exception*       result )
-{
-       struct entry_info info;
-       int             rc;
-       Modifications* modlist = NULL;
-       const char*     text = NULL;
-       BerVarray               value_array; 
-       Attribute               *uuid_attr, *attr;
-       Entry                   *e;
-       char                    textbuf[SLAP_TEXT_BUFLEN];
-       size_t                  textlen = sizeof(textbuf);
-
-       SlapReply sreply = {REP_RESULT};
-
-       Operation op_tmp = *op;
-       slap_callback cb;
-
-       sreply.sr_entry = NULL; 
-       sreply.sr_nentries = 0; 
-
-       e = ( Entry * ) ch_calloc( 1, sizeof( Entry )); 
-
-       dnPrettyNormal(0, &rs->sr_entry->e_name, &op_tmp.o_req_dn, &op_tmp.o_req_ndn, op->o_tmpmemctx);
-       ber_dupbv( &e->e_name, &op_tmp.o_req_dn );
-       ber_dupbv( &e->e_nname, &op_tmp.o_req_ndn );
-       sl_free( op_tmp.o_req_ndn.bv_val, op->o_tmpmemctx );
-       sl_free( op_tmp.o_req_dn.bv_val, op->o_tmpmemctx );
-       op_tmp.o_req_dn = e->e_name;
-       op_tmp.o_req_ndn = e->e_nname;
-
-       e->e_private = NULL;
-       e->e_attrs = NULL; 
-       e->e_bv.bv_val = NULL; 
-
-       /* add queryid attribute */     
-       value_array = (struct berval *)malloc(2 * sizeof( struct berval) );
-       ber_dupbv(value_array, query_uuid);
-       value_array[1].bv_val = NULL;
-       value_array[1].bv_len = 0;
-
-       uuid_attr = add_attribute(slap_schema.si_ad_queryid, e, value_array); 
-
-       /* append the attribute list from the fetched entry */
-       uuid_attr->a_next = rs->sr_entry->e_attrs;
-       rs->sr_entry->e_attrs = NULL;
-
-       for ( attr = e->e_attrs; attr; attr = attr->a_next ) {
-               if ( normalize_values( attr ) ) {
-                       info.err = MERGE_ERR; 
-                       result->rc = info.err;
-                       return 0;
-               }
-       }
-
-       info.entry = e;
-       info.uuid = query_uuid;
-       info.size_init = get_entry_size( rs->sr_entry, 0, 0 );
-       info.size_final = 0;
-       info.added = 0;
-       info.glue_be = op->o_bd;
-       info.err = SUCCESS;
-       cb.sc_private = &info;
-       cb.sc_response = null_response;
-
-       op_tmp.o_tag = LDAP_REQ_ADD;
-       op_tmp.o_protocol = LDAP_VERSION3;
-       op_tmp.o_callback = &cb;
-       op_tmp.o_time = slap_get_time();
-       op_tmp.o_do_not_cache = 1;
-
-       op_tmp.ora_e = e;
-       rc = op->o_bd->be_add( &op_tmp, &sreply );
-
-       if ( rc != LDAP_SUCCESS ) {
-               if ( rc == LDAP_ALREADY_EXISTS ) {
-                       slap_entry2mods( e, &modlist, &text, textbuf, textlen );
-                       op_tmp.o_tag = LDAP_REQ_MODIFY;
-                       op_tmp.orm_modlist = modlist;
-                       op_tmp.o_req_dn = e->e_name;
-                       op_tmp.o_req_ndn = e->e_nname;
-                       rc = op->o_bd->be_modify( &op_tmp, &sreply );
-                       result->rc = info.added;
-               } else if ( rc == LDAP_REFERRAL ||
-                                       rc == LDAP_NO_SUCH_OBJECT ) {
-                       syncrepl_add_glue( &op_tmp, e );
-                       result->rc = info.added;
-               } else {
-                       result->rc = 0;
-               }
-               if ( modlist != NULL ) slap_mods_free( modlist );
-       } else {
-               info.size_init = 0;
-               result->rc = info.added;
-               be_entry_release_w( &op_tmp, e );
-       }
-
-       if ( result->rc )
-               info.size_final = get_entry_size( e, info.size_init, result );
-       else
-               info.size_final = info.size_init;
-
-       return ( info.size_final - info.size_init );
-}
-
-static Attribute* 
-add_attribute(AttributeDescription *ad,
-       Entry* e, 
-       BerVarray value_array) 
-{
-       Attribute* new_attr, *last_attr; 
-       const char* text; 
-
-       if (e->e_attrs == NULL) 
-               last_attr = NULL; 
-       else 
-               for (last_attr = e->e_attrs; last_attr->a_next;
-                               last_attr = last_attr->a_next)
-                       ; 
-
-       new_attr = (Attribute*)malloc(sizeof(Attribute));               
-       if (last_attr) 
-               last_attr->a_next = new_attr;
-       else 
-               e->e_attrs = new_attr; 
-
-       new_attr->a_next = NULL; 
-       new_attr->a_desc = NULL;
-       new_attr->a_vals = value_array; 
-       new_attr->a_desc = ad;
-
-       return new_attr; 
-}
-
-static int
-null_response (
-       Operation       *op,
-       SlapReply       *rs )
-{
-       return 0;
-}
-
-static int 
-normalize_values( Attribute* attr ) 
-{
-       int nvals, rc, i; 
-       if (attr->a_vals == NULL) {
-               attr->a_nvals = NULL; 
-               return 0; 
-       } 
-
-       for ( nvals = 0; attr->a_vals[nvals].bv_val; nvals++ ) 
-               ; 
-
-       attr->a_nvals = (struct berval*)ch_malloc((nvals+1)*sizeof(struct berval));
-
-       if ( attr->a_desc->ad_type->sat_equality &&
-                               attr->a_desc->ad_type->sat_equality->smr_normalize )
-       {
-               for ( i = 0; i < nvals; i++ ) {
-                       rc = attr->a_desc->ad_type->sat_equality->smr_normalize(
-                               SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
-                               attr->a_desc->ad_type->sat_syntax,
-                               attr->a_desc->ad_type->sat_equality,
-                               &attr->a_vals[i], &attr->a_nvals[i], NULL );
-                       if ( rc ) {
-#ifdef NEW_LOGGING
-                               LDAP_LOG( OPERATION, DETAIL1,
-                                       "Error in normalizing attribute %s value %d (%d)\n",
-                                       attr->a_desc->ad_cname.bv_val, i, rc );
-#else
-                               Debug( LDAP_DEBUG_ANY,
-                                       "Error in normalizing attribute %s value %d (%d)\n",
-                                       attr->a_desc->ad_cname.bv_val, i, rc );
-#endif
-                               return rc;
-                       }
-               }
-       } else {
-               for ( i = 0; i < nvals; i++ ) {
-                       ber_dupbv( &attr->a_nvals[i], &attr->a_vals[i] ); 
-               }
-       }
-                       
-       attr->a_nvals[i].bv_val = NULL;
-       attr->a_nvals[i].bv_len = 0;
-
-       return LDAP_SUCCESS;
-}
diff --git a/servers/slapd/back-meta/cache-query.c b/servers/slapd/back-meta/cache-query.c
deleted file mode 100644 (file)
index 857b75c..0000000
+++ /dev/null
@@ -1,468 +0,0 @@
-/* $OpenLDAP$ */
-/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
- *
- * Copyright 1999-2003 The OpenLDAP Foundation.
- * Portions Copyright 2003 IBM Corporation.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted only as authorized by the OpenLDAP
- * Public License.
- *
- * A copy of this license is available in the file LICENSE in the
- * top-level directory of the distribution or, alternatively, at
- * <http://www.OpenLDAP.org/license.html>.
- */
-/* ACKNOWLEDGEMENTS:
- * This work was initially developed by the Apurva Kumar for inclusion
- * in OpenLDAP Software.
- */
-
-#include "portable.h"
-
-#include <stdio.h>
-
-#include <ac/string.h>
-
-#include "slap.h"
-#include "../back-ldap/back-ldap.h"
-#include "back-meta.h"
-
-static void    add_query_on_top (query_manager*, CachedQuery*);
-static int     base_scope_compare(struct berval* dn_stored, 
-                                  struct berval* dn_incoming, int scope_stored,
-                                  int scope_incoming);
-
-/* check whether query is contained in any of 
- * the cached queries in template template_index 
- */
-int 
-query_containment(query_manager* qm, 
-                 Query* query, 
-                 int template_index)
-{
-       QueryTemplate* templa= qm->templates;
-       CachedQuery* qc;
-       Query* q;
-       Query* prev_q;
-       Filter* inputf = query->filter; 
-       struct berval* base = &(query->base); 
-       int scope = query->scope; 
-       int i,res=0;
-       Filter* fs;
-       Filter* fi;
-       int ret, rc; 
-       const char* text; 
-
-       MatchingRule* mrule = NULL;
-       if (inputf != NULL) {
-#ifdef NEW_LOGGING
-               LDAP_LOG( BACK_META, DETAIL1, "Lock QC index = %d\n",
-                               template_index, 0, 0 );
-#else
-               Debug( LDAP_DEBUG_ANY, "Lock QC index = %d\n",
-                               template_index, 0, 0 );
-#endif
-               ldap_pvt_thread_rdwr_rlock(&(templa[template_index].t_rwlock));  
-               for(qc=templa[template_index].query; qc != NULL; qc= qc->next) {
-                       q = (Query*)qc; 
-                       if(base_scope_compare(&(q->base), base, q->scope, scope)) {
-                               fi = inputf;
-                               fs = q->filter;          
-                               do {    
-                                       res=0;
-                                       switch (fs->f_choice) {
-                                       case LDAP_FILTER_EQUALITY:
-                                               if (fi->f_choice == LDAP_FILTER_EQUALITY) 
-                                                       mrule = fs->f_ava->aa_desc->ad_type->sat_equality; 
-                                               else 
-                                                       ret = 1; 
-                                               break; 
-                                       case LDAP_FILTER_GE:
-                                       case LDAP_FILTER_LE:
-                                               mrule = fs->f_ava->aa_desc->ad_type->sat_ordering; 
-                                               break; 
-                                       default: 
-                                               mrule = NULL;   
-                                       }
-                                       if (mrule) { 
-                                               rc = value_match(&ret, fs->f_ava->aa_desc, mrule, 
-                                                       SLAP_MR_VALUE_OF_ASSERTION_SYNTAX, 
-                                                       &(fi->f_ava->aa_value), 
-                                                       &(fs->f_ava->aa_value), &text); 
-                                               if (rc != LDAP_SUCCESS) {
-#ifdef NEW_LOGGING
-                                                       LDAP_LOG( BACK_META, DETAIL1,
-                                                       "Unlock: Exiting QC index=%d\n",
-                                                       template_index, 0, 0 );
-#else
-                                                       Debug( LDAP_DEBUG_ANY,
-                                                       "Unlock: Exiting QC index=%d\n",
-                                                       template_index, 0, 0 );
-#endif
-                                                       ldap_pvt_thread_rdwr_runlock(&(templa[template_index].t_rwlock));  
-#ifdef NEW_LOGGING
-                                                       LDAP_LOG( BACK_META, DETAIL1,
-                                                       "query_containment: Required "
-                                                       "matching rule not defined for "
-                                                       "a filter attribute",
-                                                       0, 0, 0 );  
-#else
-                                                       Debug( LDAP_DEBUG_ANY,
-                                                       "query_containment: Required "
-                                                       "matching rule not defined for "
-                                                       "a filter attribute",
-                                                       0, 0, 0 );  
-#endif
-                                                       return 0; 
-                                               }
-                                       } 
-                                       switch (fs->f_choice) {
-                                       case LDAP_FILTER_OR: 
-                                       case LDAP_FILTER_AND:
-                                               fs = fs->f_and;
-                                               fi = fi->f_and;
-                                               res=1;
-                                               break; 
-                                       case LDAP_FILTER_SUBSTRINGS: 
-                                               /* check if the equality query can be 
-                                               * answered with cached substring query */
-                                               if ((fi->f_choice == LDAP_FILTER_EQUALITY)
-                                                       && substr_containment_equality(
-                                                       fs, fi))
-                                                       res=1;          
-                                               /* check if the substring query can be 
-                                               * answered with cached substring query */
-                                               if ((fi->f_choice ==LDAP_FILTER_SUBSTRINGS
-                                                       ) && substr_containment_substr(
-                                                       fs, fi))
-                                                       res= 1;
-                                               fs=fs->f_next;
-                                               fi=fi->f_next;  
-                                               break; 
-                                       case LDAP_FILTER_PRESENT: 
-                                               res=1;
-                                               fs=fs->f_next;
-                                               fi=fi->f_next;  
-                                               break; 
-                                       case LDAP_FILTER_EQUALITY: 
-                                               if (ret == 0) 
-                                                       res = 1;
-                                               fs=fs->f_next;
-                                               fi=fi->f_next;  
-                                               break; 
-                                       case LDAP_FILTER_GE: 
-                                               if (ret >= 0)
-                                                       res = 1; 
-                                               fs=fs->f_next;
-                                               fi=fi->f_next;  
-                                               break;
-                                       case LDAP_FILTER_LE: 
-                                               if (ret <= 0)
-                                                       res = 1; 
-                                               fs=fs->f_next;
-                                               fi=fi->f_next;  
-                                               break;
-                                       case LDAP_FILTER_NOT:
-                                               res=0;
-                                               break;
-                                       default:
-                                               break;
-                                       } 
-                               } while((res) && (fi != NULL) && (fs != NULL));
-
-                               if(res) {
-                                       ldap_pvt_thread_mutex_lock(&qm->lru_mutex); 
-                                       if (qm->lru_top != qc) {
-                                               remove_query(qm, qc); 
-                                               add_query_on_top(qm, qc); 
-                                       }
-                                       ldap_pvt_thread_mutex_unlock(&qm->lru_mutex); 
-                                       return 1;
-                               }       
-                       }
-               }
-#ifdef NEW_LOGGING
-               LDAP_LOG( BACK_META, DETAIL1,
-                       "Not answerable: Unlock QC index=%d\n",
-                       template_index, 0, 0 );
-#else
-               Debug( LDAP_DEBUG_ANY,
-                       "Not answerable: Unlock QC index=%d\n",
-                       template_index, 0, 0 );
-#endif
-               ldap_pvt_thread_rdwr_runlock(&(templa[template_index].t_rwlock));  
-       }
-       return 0; 
-}
-
-/* remove_query from LRU list */
-
-void 
-remove_query (query_manager* qm, CachedQuery* qc) 
-{
-       CachedQuery* up; 
-       CachedQuery* down; 
-
-       if (!qc) 
-               return; 
-
-       up = qc->lru_up; 
-       down = qc->lru_down; 
-
-       if (!up) 
-               qm->lru_top = down; 
-
-       if (!down) 
-               qm->lru_bottom = up; 
-
-       if (down) 
-               down->lru_up = up; 
-
-       if (up) 
-               up->lru_down = down; 
-
-       qc->lru_up = qc->lru_down = NULL; 
-}
-
-/* add query on top of LRU list */
-void 
-add_query_on_top (query_manager* qm, CachedQuery* qc) 
-{
-       CachedQuery* top = qm->lru_top; 
-       Query* q = (Query*)qc; 
-    
-       qm->lru_top = qc; 
-
-       if (top) 
-               top->lru_up = qc; 
-       else
-               qm->lru_bottom = qc; 
-       
-       qc->lru_down = top; 
-       qc->lru_up = NULL; 
-#ifdef NEW_LOGGING
-       LDAP_LOG( BACK_META, DETAIL1, "Base of added query = %s\n",
-                       q->base.bv_val, 0, 0 );
-#else
-       Debug( LDAP_DEBUG_ANY, "Base of added query = %s\n",
-                       q->base.bv_val, 0, 0 );
-#endif
-}
-
-void 
-free_query (CachedQuery* qc) 
-{
-       Query* q = (Query*)qc; 
-       free(qc->q_uuid); 
-       filter_free(q->filter); 
-       free (q->base.bv_val); 
-
-       free(q->attrs); 
-       free(qc); 
-}
-
-/* compare base and scope of incoming and cached queries */
-int base_scope_compare(
-       struct berval* dn_stored, 
-       struct berval* dn_incoming, 
-       int scope_stored, 
-       int scope_incoming      )
-{
-       struct berval ndn_incoming = { 0L, NULL }; 
-       struct berval pdn_incoming = { 0L, NULL };
-       struct berval ndn_stored = { 0L, NULL };
-
-       int i;
-
-       if (scope_stored < scope_incoming)
-               return 0;
-
-       dnNormalize(0, NULL, NULL, dn_incoming, &ndn_incoming, NULL);
-       dnNormalize(0, NULL, NULL, dn_stored, &ndn_stored, NULL);
-       
-       i = dnIsSuffix(&ndn_incoming, &ndn_stored);
-       
-       if ( i == 0 )
-               return 0;
-       
-       switch(scope_stored) {
-       case LDAP_SCOPE_BASE:
-               if (strlen(ndn_incoming.bv_val) == strlen(ndn_stored.bv_val))
-                       return 1;
-               else    
-                       return 0;
-               break;
-       case LDAP_SCOPE_ONELEVEL:
-               switch(scope_incoming){
-               case LDAP_SCOPE_BASE:
-                       dnParent(&ndn_incoming, &pdn_incoming); 
-                       if(strcmp(pdn_incoming.bv_val, ndn_stored.bv_val) == 0)
-                               return 1;
-                       else
-                               return 0;
-                       break;
-               case LDAP_SCOPE_ONELEVEL:
-                       if (ndn_incoming.bv_len == ndn_stored.bv_len)
-                               return 1;
-                       else
-                               return 0;
-                       break;
-               default:
-                       return 0;
-                       break;
-               }
-       case LDAP_SCOPE_SUBTREE:
-               return 1;
-               break;
-       default:
-               return 0;
-               break;  
-    }
-}
-
-/* Add query to query cache */
-void add_query(
-       query_manager* qm, 
-       Query* query, 
-       int template_index, 
-       char* uuid, 
-       struct exception* result)
-{
-       CachedQuery* new_cached_query = (CachedQuery*) malloc(sizeof(CachedQuery));
-       QueryTemplate* templ = (qm->templates)+template_index;  
-       Query* new_query;
-       new_cached_query->template_id = template_index; 
-       new_cached_query->q_uuid = uuid; 
-       new_cached_query->lru_up = NULL; 
-       new_cached_query->lru_down = NULL; 
-       new_cached_query->expiry_time = slap_get_time() + templ->ttl; 
-#ifdef NEW_LOGGING
-       LDAP_LOG( BACK_META, DETAIL1, "Added query expires at %ld\n",
-                       (long) new_cached_query->expiry_time, 0, 0 );
-#else
-       Debug( LDAP_DEBUG_ANY, "Added query expires at %ld\n",
-                       (long) new_cached_query->expiry_time, 0, 0 );
-#endif
-       new_query = (Query*)new_cached_query; 
-
-       new_query->base.bv_val = ch_strdup(query->base.bv_val); 
-       new_query->base.bv_len = query->base.bv_len; 
-       new_query->scope = query->scope; 
-       new_query->filter = query->filter;
-       new_query->attrs = query->attrs; 
-
-       /* Adding a query    */
-#ifdef NEW_LOGGING
-       LDAP_LOG( BACK_META, DETAIL1, "Lock AQ index = %d\n",
-                       template_index, 0, 0 );
-#else
-       Debug( LDAP_DEBUG_ANY, "Lock AQ index = %d\n",
-                       template_index, 0, 0 );
-#endif
-       ldap_pvt_thread_rdwr_wlock(&templ->t_rwlock);  
-       if (templ->query == NULL) 
-               templ->query_last = new_cached_query; 
-       else 
-               templ->query->prev = new_cached_query; 
-       new_cached_query->next = templ->query; 
-       new_cached_query->prev = NULL; 
-       templ->query = new_cached_query; 
-       templ->no_of_queries++; 
-#ifdef NEW_LOGGING
-       LDAP_LOG( BACK_META, DETAIL1, "TEMPLATE %d QUERIES++ %d\n",
-                       template_index, templ->no_of_queries, 0 );
-#else
-       Debug( LDAP_DEBUG_ANY, "TEMPLATE %d QUERIES++ %d\n",
-                       template_index, templ->no_of_queries, 0 );
-#endif
-
-#ifdef NEW_LOGGING
-       LDAP_LOG( BACK_META, DETAIL1, "Unlock AQ index = %d \n",
-                       template_index, 0, 0 );
-#else
-       Debug( LDAP_DEBUG_ANY, "Unlock AQ index = %d \n",
-                       template_index, 0, 0 );
-#endif
-       ldap_pvt_thread_rdwr_wunlock(&templ->t_rwlock);  
-
-       /* Adding on top of LRU list  */
-       ldap_pvt_thread_mutex_lock(&qm->lru_mutex); 
-       add_query_on_top(qm, new_cached_query);  
-       ldap_pvt_thread_mutex_unlock(&qm->lru_mutex); 
-
-}      
-
-/* remove bottom query of LRU list from the query cache */     
-char* cache_replacement(query_manager* qm)
-{
-       char* result = (char*)(malloc(40));
-       CachedQuery* bottom; 
-       QueryTemplate* templ; 
-       CachedQuery* query_curr; 
-       int temp_id;
-
-       ldap_pvt_thread_mutex_lock(&qm->lru_mutex); 
-       bottom = qm->lru_bottom; 
-
-       if (!bottom) {
-#ifdef NEW_LOGGING
-               LDAP_LOG ( BACK_META, DETAIL1,
-                       "Cache replacement invoked without "
-                       "any query in LRU list\n", 0, 0, 0 );
-#else
-               Debug ( LDAP_DEBUG_ANY,
-                       "Cache replacement invoked without "
-                       "any query in LRU list\n", 0, 0, 0 );
-#endif
-               return 0; 
-       }
-
-       temp_id = bottom->template_id;
-       remove_query(qm, bottom); 
-       ldap_pvt_thread_mutex_unlock(&qm->lru_mutex); 
-
-       strcpy(result, bottom->q_uuid); 
-
-#ifdef NEW_LOGGING
-       LDAP_LOG( BACK_META, DETAIL1, "Lock CR index = %d\n", temp_id, 0, 0 );
-#else
-       Debug( LDAP_DEBUG_ANY, "Lock CR index = %d\n", temp_id, 0, 0 );
-#endif
-       ldap_pvt_thread_rdwr_wlock(&(qm->templates[temp_id].t_rwlock));  
-       remove_from_template(bottom, (qm->templates+temp_id)); 
-#ifdef NEW_LOGGING
-       LDAP_LOG( BACK_META, DETAIL1, "TEMPLATE %d QUERIES-- %d\n",
-               temp_id, qm->templates[temp_id].no_of_queries, 0 );
-#else
-       Debug( LDAP_DEBUG_ANY, "TEMPLATE %d QUERIES-- %d\n",
-               temp_id, qm->templates[temp_id].no_of_queries, 0 );
-#endif
-#ifdef NEW_LOGGING
-       LDAP_LOG( BACK_META, DETAIL1, "Unlock CR index = %d\n", temp_id, 0, 0 );
-#else
-       Debug( LDAP_DEBUG_ANY, "Unlock CR index = %d\n", temp_id, 0, 0 );
-#endif
-       ldap_pvt_thread_rdwr_wunlock(&(qm->templates[temp_id].t_rwlock));  
-       free_query(bottom); 
-       return result; 
-}
-
-void
-remove_from_template (CachedQuery* qc, QueryTemplate* template)
-{
-       if (!qc->prev && !qc->next) {
-               template->query_last = template->query = NULL; 
-       } else if (qc->prev == NULL) {
-               qc->next->prev = NULL; 
-               template->query = qc->next; 
-       } else if (qc->next == NULL) {
-               qc->prev->next = NULL; 
-               template->query_last = qc->prev; 
-       } else {
-               qc->next->prev = qc->prev; 
-               qc->prev->next = qc->next; 
-       }
-
-       template->no_of_queries--;  
-}    
diff --git a/servers/slapd/back-meta/cache-remove.c b/servers/slapd/back-meta/cache-remove.c
deleted file mode 100644 (file)
index 5f6e34c..0000000
+++ /dev/null
@@ -1,191 +0,0 @@
-/* $OpenLDAP$ */
-/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
- *
- * Copyright 1999-2003 The OpenLDAP Foundation.
- * Portions Copyright 2003 IBM Corporation.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted only as authorized by the OpenLDAP
- * Public License.
- *
- * A copy of this license is available in the file LICENSE in the
- * top-level directory of the distribution or, alternatively, at
- * <http://www.OpenLDAP.org/license.html>.
- */
-/* ACKNOWLEDGEMENTS:
- * This work was initially developed by the Apurva Kumar for inclusion
- * in OpenLDAP Software.
- */
-
-#include "portable.h"
-
-#include <stdio.h>
-
-#include <ac/socket.h>
-#include <ac/string.h>
-#include <ac/time.h>
-
-#include "slap.h"
-#include "ldif.h"
-#include "../back-ldap/back-ldap.h"
-#include "back-meta.h"
-#include "ldap_pvt.h"
-#undef ldap_debug      /* silence a warning in ldap-int.h */
-#include "ldap_log.h"
-#include "../../../libraries/libldap/ldap-int.h"
-#include <sys/time.h>
-
-static int
-remove_func (
-       Operation       *op,
-       SlapReply       *rs
-);
-struct query_info {
-       int                     freed; 
-       int                     deleted; 
-       struct berval*          uuid; 
-       struct timeval          tv; 
-       enum type_of_result     err; 
-}; 
-   
-int 
-remove_query_data (
-       Operation       *op,
-       SlapReply       *rs,
-       struct berval* query_uuid, 
-       struct exception* result)
-{
-       struct query_info       info; 
-       char                    filter_str[64]; 
-       Operation               op_tmp = *op;
-       Filter                  *filter; 
-       long timediff;
-       SlapReply               sreply = {REP_RESULT}; 
-       slap_callback cb = { remove_func, NULL }; 
-
-       sreply.sr_entry = NULL; 
-       sreply.sr_nentries = 0; 
-       snprintf(filter_str, sizeof(filter_str), "(queryid=%s)",
-                       query_uuid->bv_val);
-       filter = str2filter(filter_str);              
-       info.uuid = query_uuid; 
-       info.freed = 0; 
-       info.deleted = 0; 
-       info.err = SUCCESS; 
-       cb.sc_private = &info; 
-       op_tmp.o_tag = LDAP_REQ_SEARCH;
-       op_tmp.o_protocol = LDAP_VERSION3;
-       op_tmp.o_callback = &cb;
-       op_tmp.o_time = slap_get_time();
-       op_tmp.o_do_not_cache = 1;
-
-       op_tmp.o_req_dn = op->o_bd->be_suffix[0];
-       op_tmp.o_req_ndn = op->o_bd->be_nsuffix[0];
-       op_tmp.ors_scope = LDAP_SCOPE_SUBTREE;
-       op_tmp.ors_deref = LDAP_DEREF_NEVER;
-       op_tmp.ors_slimit = 0;
-       op_tmp.ors_tlimit = 0;
-       op_tmp.ors_filter = filter;
-       op_tmp.ors_filterstr.bv_val = filter_str;
-       op_tmp.ors_filterstr.bv_len = strlen(filter_str);
-       op_tmp.ors_attrs = NULL;
-       op_tmp.ors_attrsonly = 0;
-
-       op->o_bd->be_search( &op_tmp, &sreply );
-
-       result->type = info.err;  
-       result->rc = info.deleted; 
-
-       return info.freed;  
-}
-
-static int
-remove_func (
-       Operation       *op,
-       SlapReply       *rs
-)
-{
-       struct query_info       *info = op->o_callback->sc_private;
-       int                     count = 0;
-       int                     size;
-       long                    timediff;
-       Modifications           *mod;
-
-       Attribute               *attr;
-       Operation               op_tmp = *op;
-
-       SlapReply               sreply = {REP_RESULT}; 
-
-       if (rs->sr_type == REP_RESULT) 
-               return 0; 
-
-       size = get_entry_size(rs->sr_entry, 0, NULL);
-
-       for (attr = rs->sr_entry->e_attrs; attr!= NULL; attr = attr->a_next) {
-               if (attr->a_desc == slap_schema.si_ad_queryid) {
-                       for (count=0; attr->a_vals[count].bv_val; count++) 
-                               ;
-                       break; 
-               }
-       }       
-
-       if (count == 0) {
-               info->err = REMOVE_ERR; 
-               return 0; 
-       }
-       if (count == 1) {
-               info->freed += size; 
-#ifdef NEW_LOGGING
-               LDAP_LOG( BACK_META, DETAIL1,
-                               "DELETING ENTRY SIZE=%d TEMPLATE=%s\n",
-                               size, attr->a_vals[0].bv_val, 0 );
-#else
-               Debug( LDAP_DEBUG_ANY, "DELETING ENTRY SIZE=%d TEMPLATE=%s\n",
-                               size, attr->a_vals[0].bv_val, 0 );
-#endif
-
-               op_tmp.o_req_dn = rs->sr_entry->e_name;
-               op_tmp.o_req_ndn = rs->sr_entry->e_nname;
-
-               if (op->o_bd->be_delete(&op_tmp, rs)) {
-                       info->err = REMOVE_ERR; 
-               } else {
-                       info->deleted++; 
-               }
-               return 0; 
-       }
-
-       mod = (Modifications*)malloc(sizeof(Modifications)); 
-       mod->sml_op = LDAP_MOD_DELETE; 
-       mod->sml_type.bv_len = sizeof("queryid"); 
-       mod->sml_type.bv_val = "queryid"; 
-       mod->sml_desc = slap_schema.si_ad_queryid;   
-       mod->sml_bvalues = (struct berval*) malloc( 2 * sizeof( struct berval) );
-       ber_dupbv(mod->sml_bvalues, info->uuid); 
-       mod->sml_bvalues[1].bv_val = NULL; 
-       mod->sml_bvalues[1].bv_len = 0; 
-       mod->sml_next = NULL; 
-#ifdef NEW_LOGGING
-       LDAP_LOG( BACK_META, DETAIL1,
-                       "REMOVING TEMP ATTR : TEMPLATE=%s\n",
-                       attr->a_vals[0].bv_val, 0, 0 );
-#else
-       Debug( LDAP_DEBUG_ANY, "REMOVING TEMP ATTR : TEMPLATE=%s\n",
-                       attr->a_vals[0].bv_val, 0, 0 );
-#endif
-
-       op_tmp.o_req_dn = rs->sr_entry->e_name;
-       op_tmp.o_req_ndn = rs->sr_entry->e_nname;
-       op_tmp.orm_modlist = mod;
-       
-       if (op->o_bd->be_modify( &op_tmp, &sreply )) {
-               info->err = REMOVE_ERR;
-       }
-
-       info->freed += LDIF_SIZE_NEEDED(9, (strlen(info->uuid->bv_val))); 
-
-       return 0;
-}
diff --git a/servers/slapd/back-meta/cache-search.c b/servers/slapd/back-meta/cache-search.c
deleted file mode 100644 (file)
index e31b1c1..0000000
+++ /dev/null
@@ -1,1847 +0,0 @@
-/* $OpenLDAP$ */
-/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
- *
- * Copyright 1999-2003 The OpenLDAP Foundation.
- * Portions Copyright 2003 IBM Corporation.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted only as authorized by the OpenLDAP
- * Public License.
- *
- * A copy of this license is available in the file LICENSE in the
- * top-level directory of the distribution or, alternatively, at
- * <http://www.OpenLDAP.org/license.html>.
- */
-/* ACKNOWLEDGEMENTS:
- * This work was initially developed by the Howard Chu for inclusion
- * in OpenLDAP Software and subsequently enhanced by Pierangelo
- * Masarati and Apurva Kumar.
- */
-/* This is an altered version */
-/*
- * This software is based on the backends back-ldap and back-meta, implemented
- * by Howard Chu <hyc@highlandsun.com>, Mark Valence
- * <kurash@sassafras.com>, Pierangelo Masarati <ando@sys-net.it> and other
- * contributors. 
- *
- * The original copyright statements follow. 
- * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
- *
- * Copyright 2001, Pierangelo Masarati, All rights reserved. <ando@sys-net.it>
- *
- * This work has been developed to fulfill the requirements
- * of SysNet s.n.c. <http:www.sys-net.it> and it has been donated
- * to the OpenLDAP Foundation in the hope that it may be useful
- * to the Open Source community, but WITHOUT ANY WARRANTY.
- *
- * Permission is granted to anyone to use this software for any purpose
- * on any computer system, and to alter it and redistribute it, subject
- * to the following restrictions:
- *
- * 1. The author and SysNet s.n.c. are not responsible for the consequences
- *    of use of this software, no matter how awful, even if they arise from 
- *    flaws in it.
- *
- * 2. The origin of this software must not be misrepresented, either by
- *    explicit claim or by omission.  Since few users ever read sources,
- *    credits should appear in the documentation.
- *
- * 3. Altered versions must be plainly marked as such, and must not be
- *    misrepresented as being the original software.  Since few users
- *    ever read sources, credits should appear in the documentation.
- *    SysNet s.n.c. cannot be responsible for the consequences of the
- *    alterations.
- *
- * 4. This notice may not be removed or altered.
- *
- *
- * This software is based on the backend back-ldap, implemented
- * by Howard Chu <hyc@highlandsun.com>, and modified by Mark Valence
- * <kurash@sassafras.com>, Pierangelo Masarati <ando@sys-net.it> and other
- * contributors. The contribution of the original software to the present
- * implementation is acknowledged in this copyright statement.
- *
- * A special acknowledgement goes to Howard for the overall architecture
- * (and for borrowing large pieces of code), and to Mark, who implemented
- * from scratch the attribute/objectclass mapping.
- *
- * The original copyright statement follows.
- *
- * Copyright 1999, Howard Chu, All rights reserved. <hyc@highlandsun.com>
- *
- * Permission is granted to anyone to use this software for any purpose
- * on any computer system, and to alter it and redistribute it, subject
- * to the following restrictions:
- *
- * 1. The author is not responsible for the consequences of use of this
- *    software, no matter how awful, even if they arise from flaws in it.
- *
- * 2. The origin of this software must not be misrepresented, either by
- *    explicit claim or by omission.  Since few users ever read sources,
- *    credits should appear in the documentation.
- *
- * 3. Altered versions must be plainly marked as such, and must not be
- *    misrepresented as being the original software.  Since few users
- *    ever read sources, credits should appear in the
- *    documentation.
- *
- * 4. This notice may not be removed or altered.
- *                
- */
-#include "portable.h"
-
-#include <stdio.h>
-
-#include <ac/socket.h>
-#include <ac/string.h>
-#include <ac/time.h>
-
-#include "ldap_pvt.h"
-#include "lutil.h"
-#include "slap.h"
-#include "../back-ldap/back-ldap.h"
-#include "back-meta.h"
-#undef ldap_debug      /* silence a warning in ldap-int.h */
-#include "ldap_log.h"
-#include "../../../libraries/libldap/ldap-int.h"
-
-static Entry* 
-meta_create_entry(
-       Backend         *be,
-       struct metaconn *lc,
-       int             target,
-       LDAPMessage     *e,
-       struct exception* result
-); 
-
-static int
-is_one_level_rdn(
-       const char      *rdn,
-       int             from
-);
-
-static struct metaconn*  
-metaConnect(
-       Operation               *op, 
-       SlapReply               *rs,
-       int                     op_type, 
-       struct berval           *nbase, 
-       struct exception        *result 
-);
-
-static void
-add_filter_attrs(
-       AttributeName** newattrs, 
-       AttributeName* attrs, 
-       AttributeName* filter_attrs
-);
-
-static int 
-handleLdapResult(
-       struct metaconn* lc, 
-       Operation* op, 
-       SlapReply *rs,
-       int* msgid, Backend* be, 
-       AttributeName* attrs, 
-       int attrsonly, 
-       int candidates, 
-       int cacheable, 
-       Entry*** entry_array, 
-       int curr_limit, 
-       int slimit,
-       struct exception* result
-);
-
-static Entry* 
-get_result_entry(
-       Backend* be,
-       struct metaconn* lc, 
-       struct metasingleconn* lsc, 
-       int* msgid,
-       int i, 
-       struct timeval* tv, 
-       struct exception* result
-); 
-
-static void
-rewriteSession(
-       struct rewrite_info* info, 
-       const char* rewriteContext, 
-       const char* string, 
-       const void* cookie,  
-       char** base, 
-       struct exception* result
-);
-
-static int 
-get_attr_set(
-       AttributeName* attrs, 
-       query_manager* qm, 
-       int num
-);
-
-static int 
-attrscmp(
-       AttributeName* attrs_in, 
-       AttributeName* attrs
-);
-
-static char* 
-cache_entries(
-       Operation       *op,
-       SlapReply       *rs,
-       Entry** entry_array, 
-       cache_manager* cm, 
-       struct exception* result
-); 
-
-static int 
-is_temp_answerable(
-       int attr_set, 
-       struct berval* tempstr, 
-       query_manager* qm, 
-       int template_id
-);
-
-static void*
-consistency_check(
-       void    *op
-); 
-
-static int
-cache_back_sentry(
-       Operation* op, 
-       SlapReply *rs
-);
-
-
-int
-meta_back_cache_search(
-       Operation       *op,
-       SlapReply       *rs )
-       /*
-       Backend         *be,
-       Connection      *conn,
-       Operation       *op,
-       struct berval   *base,
-       struct berval   *nbase,
-       int             scope,
-       int             deref,
-       int             slimit,
-       int             tlimit,
-       Filter          *filt,
-       struct berval   *filterstr,
-       AttributeName   *attributes,
-       int             attrsonly
-) */
-{
-       struct metainfo         *li = ( struct metainfo * )op->o_bd->be_private;
-       struct metaconn         *lc;
-       struct metasingleconn   *lsc;
-       cache_manager*          cm = li->cm; 
-       query_manager*          qm = cm->qm; 
-
-       Operation               *oper;
-
-       time_t                  curr_time; 
-
-       int count, rc = 0, *msgid = NULL; 
-       char *mbase = NULL;
-       char *cbase = NULL; 
-       char *uuid; 
-           
-       int i = -1, last = 0, candidates = 0, op_type;
-
-       struct berval   mfilter;
-       struct berval   cachebase = { 0L, NULL };  
-       struct berval   ncachebase = { 0L, NULL };  
-       struct berval   cache_suffix; 
-       struct berval   tempstr = { 0L, NULL }; 
-
-       AttributeName   *filter_attrs = NULL; 
-       AttributeName   *new_attrs = NULL; 
-       AttributeName   *attrs = NULL; 
-
-       Entry           *e;
-       Entry           **entry_array = NULL;
-
-       Query           query; 
-
-       int             attr_set = -1; 
-       int             template_id = -1; 
-       int             answerable = 0; 
-       int             cacheable = 0; 
-       int             num_entries = 0;
-       int             curr_limit;
-       int             fattr_cnt=0; 
-       int             oc_attr_absent = 1;
-
-       struct exception result[1]; 
-
-       Filter* filter = str2filter(op->ors_filterstr.bv_val); 
-       slap_callback cb = {cache_back_sentry, NULL}; 
-
-       cb.sc_private = op->o_bd; 
-
-       if (op->ors_attrs) {
-               for ( count=0; op->ors_attrs[ count ].an_name.bv_val; count++ ) {
-                       if ( op->ors_attrs[count].an_desc == slap_schema.si_ad_objectClass )
-                               oc_attr_absent = 0;
-               }
-               attrs = (AttributeName*)malloc( ( count + 1 + oc_attr_absent )
-                                                               *sizeof(AttributeName));
-               for ( count=0; op->ors_attrs[ count ].an_name.bv_val; count++ ) {
-                       ber_dupbv(&attrs[ count ].an_name,
-                                               &op->ors_attrs[ count ].an_name);
-                       attrs[count].an_desc = op->ors_attrs[count].an_desc; 
-               }
-               attrs[ count ].an_name.bv_val = NULL;
-               attrs[ count ].an_name.bv_len = 0;
-       }
-
-       result->type = SUCCESS; 
-       result->rc = 0; 
-       ldap_pvt_thread_mutex_lock(&cm->cache_mutex); 
-       cm->threads++; 
-#ifdef NEW_LOGGING
-       LDAP_LOG( BACK_META, DETAIL1, "Threads++ = %d\n", cm->threads, 0, 0 );
-#else /* !NEW_LOGGING */
-       Debug( LDAP_DEBUG_ANY, "Threads++ = %d\n", cm->threads, 0, 0 );
-#endif /* !NEW_LOGGING */
-       ldap_pvt_thread_mutex_unlock(&cm->cache_mutex); 
-       
-       ldap_pvt_thread_mutex_lock(&cm->cc_mutex); 
-       if (!cm->cc_thread_started) {
-               oper = (Operation*)malloc(sizeof(Operation)); 
-               *oper = *op; 
-               cm->cc_thread_started = 1; 
-                ldap_pvt_thread_create(&(cm->cc_thread), 1, consistency_check, (void*)oper); 
-       }       
-       ldap_pvt_thread_mutex_unlock(&cm->cc_mutex); 
-
-       filter2template(filter, &tempstr, &filter_attrs, &fattr_cnt, result);  
-       if (result->type != SUCCESS) 
-               goto Catch; 
-
-#ifdef NEW_LOGGING
-       LDAP_LOG( BACK_META, DETAIL1, "query template of incoming query = %s\n",
-                                       tempstr.bv_val, 0, 0 );
-#else /* !NEW_LOGGING */
-       Debug( LDAP_DEBUG_ANY, "query template of incoming query = %s\n",
-                                       tempstr.bv_val, 0, 0 );
-#endif /* !NEW_LOGGING */
-       curr_limit = cm->num_entries_limit ;
-
-       /* find attr set */     
-       attr_set = get_attr_set(attrs, qm, cm->numattrsets); 
-    
-       query.filter = filter; 
-       query.attrs = attrs; 
-       query.base = op->o_req_dn; 
-       query.scope = op->ors_scope; 
-
-       /* check for query containment */
-       if (attr_set > -1) {
-               for (i=0; i<cm->numtemplates; i++) {
-                       /* find if template i can potentially answer tempstr */
-                       if (!is_temp_answerable(attr_set, &tempstr, qm, i)) 
-                               continue; 
-                       if (attr_set == qm->templates[i].attr_set_index) {
-                               cacheable = 1; 
-                               template_id = i; 
-                       }
-#ifdef NEW_LOGGING
-                       LDAP_LOG( BACK_META, DETAIL2,
-                                       "Entering QC, querystr = %s\n",
-                                       op->ors_filterstr.bv_val, 0, 0 );
-#else /* !NEW_LOGGING */
-                       Debug( LDAP_DEBUG_NONE, "Entering QC, querystr = %s\n",
-                                       op->ors_filterstr.bv_val, 0, 0 );
-#endif /* !NEW_LOGGING */
-                       answerable = (*(qm->qcfunc))(qm, &query, i);
-
-                       if (answerable)
-                               break;
-               }
-       }
-
-       if ( attrs && oc_attr_absent ) {
-               for ( count = 0; attrs[count].an_name.bv_val; count++) ;
-               attrs[ count ].an_name.bv_val = "objectClass";
-               attrs[ count ].an_name.bv_len = strlen( "objectClass" );
-               attrs[ count ].an_desc = slap_schema.si_ad_objectClass;
-               attrs[ count + 1 ].an_name.bv_val = NULL;
-               attrs[ count + 1 ].an_name.bv_len = 0;
-       }
-
-       if (answerable) {
-               Operation       op_tmp;
-
-#ifdef NEW_LOGGING
-               LDAP_LOG( BACK_META, DETAIL1, "QUERY ANSWERABLE\n", 0, 0, 0 );
-#else /* !NEW_LOGGING */
-               Debug( LDAP_DEBUG_ANY, "QUERY ANSWERABLE\n", 0, 0, 0 );
-#endif /* !NEW_LOGGING */
-               rewriteSession(li->rwinfo, "cacheBase", op->o_req_dn.bv_val,
-                                       op->o_conn, &cbase, result); 
-               if (result->type != SUCCESS) { 
-                       ldap_pvt_thread_rdwr_runlock(&qm->templates[i].t_rwlock); 
-                       goto Catch; 
-               }
-               if ( cbase == NULL ) {
-                       cachebase = op->o_req_dn;
-               } else {
-                       cachebase.bv_val = cbase;
-                       cachebase.bv_len = strlen(cbase);
-               }
-               dnNormalize(0, NULL, NULL, &cachebase, &ncachebase,
-                               op->o_tmpmemctx); 
-
-               /* FIXME: safe default? */
-               op_tmp = *op;
-
-               op_tmp.o_bd = li->glue_be;
-               op_tmp.o_req_dn = cachebase;
-               op_tmp.o_req_ndn = ncachebase;
-
-               op_tmp.o_callback = &cb; 
-
-               li->glue_be->be_search(&op_tmp, rs);
-               free( ncachebase.bv_val );
-               if ( cachebase.bv_val != op->o_req_dn.bv_val ) {
-                       /* free only if rewritten */
-                       free( cachebase.bv_val );
-               }
-
-               ldap_pvt_thread_rdwr_runlock(&qm->templates[i].t_rwlock); 
-       } else {
-               Operation       op_tmp;
-               op_tmp = *op;
-#ifdef NEW_LOGGING
-               LDAP_LOG( BACK_META, DETAIL1, "QUERY NOT ANSWERABLE\n",
-                                       0, 0, 0 );
-#else /* !NEW_LOGGING */
-               Debug( LDAP_DEBUG_ANY, "QUERY NOT ANSWERABLE\n", 0, 0, 0 );
-#endif /* !NEW_LOGGING */
-
-               if ( op->ors_scope == LDAP_SCOPE_BASE ) {
-                       op_type = META_OP_REQUIRE_SINGLE;
-               } else {
-                       op_type = META_OP_ALLOW_MULTIPLE;
-               }
-
-               lc = metaConnect(&op_tmp, rs, op_type,
-                               &op->o_req_ndn, result);
-
-               if (result->type != SUCCESS) 
-                       goto Catch; 
-
-               ldap_pvt_thread_mutex_lock(&cm->cache_mutex); 
-               if (cm->num_cached_queries >= cm->max_queries) {
-                       cacheable = 0; 
-               }
-               ldap_pvt_thread_mutex_unlock(&cm->cache_mutex); 
-               
-               if (cacheable) {
-                       add_filter_attrs(&new_attrs, attrs, filter_attrs);
-               } else {
-                       new_attrs = attrs; 
-               }
-
-               free(filter_attrs); 
-       
-               /*
-                * Array of message id of each target
-                */
-               msgid = ch_calloc( sizeof( int ), li->ntargets );
-               if ( msgid == NULL ) {
-                       result->type = CONN_ERR; 
-                       goto Catch; 
-               }
-
-               /*
-               if (slimit > 0 &&  (slimit <= cm->num_entries_limit))  
-                       slimit = cm->num_entries_limit; 
-               */
-
-               /*
-                * Inits searches
-                */
-
-               for ( i = 0, lsc = lc->conns; !META_LAST(lsc); ++i, ++lsc ) {
-                       char    *realbase = ( char * )op->o_req_dn.bv_val;
-                       int     realscope = op->ors_scope;
-                       ber_len_t suffixlen;
-                       char    *mapped_filter, **mapped_attrs;
-
-                       /* FIXME: Check for more than one targets */
-                       if ( meta_back_is_candidate(
-                                       &li->targets[i]->suffix,
-                                       &op->o_req_ndn ))
-                               lsc->candidate = META_CANDIDATE; 
-
-                       if ( lsc->candidate != META_CANDIDATE ) 
-                               continue;
-
-                       if ( op->ors_deref != -1 ) {
-                               ldap_set_option( lsc->ld, LDAP_OPT_DEREF,
-                                               ( void * )&op->ors_deref);
-                       }
-                       if ( op->ors_tlimit != -1 ) {
-                               ldap_set_option( lsc->ld, LDAP_OPT_TIMELIMIT,
-                                               ( void * )&op->ors_tlimit);
-                       }
-                       if ( op->ors_slimit != -1 ) {
-                               ldap_set_option( lsc->ld, LDAP_OPT_SIZELIMIT,
-                                               ( void * )&op->ors_slimit);
-                       }
-
-                       /*
-                        * modifies the base according to the scope, if required
-                        */
-                       suffixlen = li->targets[ i ]->suffix.bv_len;
-                       if ( suffixlen > op->o_req_ndn.bv_len ) {
-                               switch ( op->ors_scope ) {
-                               case LDAP_SCOPE_SUBTREE:
-                                       /*
-                                        * make the target suffix the new base
-                                        * FIXME: this is very forgiving,
-                                        * because illegal bases may be turned
-                                        * into the suffix of the target.
-                                        */
-                                       if ( dnIsSuffix(
-                                               &li->targets[ i ]->suffix,
-                                               &op->o_req_ndn ) ) {
-                                               realbase =
-                                               li->targets[i]->suffix.bv_val;
-                                       } else {
-                                               /*
-                                                * this target is no longer
-                                                * candidate
-                                                */
-                                               lsc->candidate =
-                                                       META_NOT_CANDIDATE;
-                                               continue;
-                                       }
-                                       break;
-
-                               case LDAP_SCOPE_ONELEVEL:
-                                       if ( is_one_level_rdn(
-                                               li->targets[ i ]->suffix.bv_val,
-                                               suffixlen - op->o_req_ndn.bv_len - 1 )
-                                               && dnIsSuffix(
-                                               &li->targets[ i ]->suffix,
-                                               &op->o_req_ndn ) ) {
-                                               /*
-                                                * if there is exactly one
-                                                * level, make the target suffix
-                                                * the new base, and make scope
-                                                * "base"
-                                                */
-                                               realbase =
-                                               li->targets[i]->suffix.bv_val;
-                                               realscope = LDAP_SCOPE_BASE;
-                                               break;
-                                       } /* else continue with the next case */
-
-                               case LDAP_SCOPE_BASE:
-                                       /*
-                                        * this target is no longer candidate
-                                        */
-                                       lsc->candidate = META_NOT_CANDIDATE;
-                                       continue;
-                               }
-                       }
-
-                       /*
-                        * Rewrite the search base, if required
-                        */
-
-                       rewriteSession(li->targets[i]->rwmap.rwm_rw,
-                                       "searchBase",
-                                       realbase, op->o_conn, &mbase, result); 
-
-                       if (result->type != SUCCESS)
-                               goto Catch; 
-
-                       if ( mbase == NULL ) {
-                               mbase = realbase;
-                       }
-
-                       /*
-                        * Rewrite the search filter, if required
-                        */
-                       rewriteSession( li->targets[i]->rwmap.rwm_rw,
-                                       "searchFilter",
-                                       op->ors_filterstr.bv_val, op->o_conn,
-                                       &mfilter.bv_val, result);
-                       if (result->type != SUCCESS) 
-                               goto Catch; 
-
-                       if ( mfilter.bv_val != NULL && mfilter.bv_val[ 0 ]
-                                                               != '\0') {
-                               mfilter.bv_len = strlen( mfilter.bv_val );
-                       } else {
-                               if ( mfilter.bv_val != NULL ) {
-                                       free( mfilter.bv_val );
-                               }
-                               mfilter = op->ors_filterstr;
-                       }
-
-#if 0
-                       /*
-                        * Maps attributes in filter
-                        */
-                       mapped_filter = ldap_back_map_filter(
-                                       &li->targets[i]->rwmap.rwm_at,
-                                       &li->targets[i]->rwmap.rwm_oc,
-                                       &mfilter, 0 );
-                       if ( mapped_filter == NULL ) {
-                               mapped_filter = ( char * )mfilter.bv_val;
-                       } else {
-                               if ( mfilter.bv_val != op->ors_filterstr.bv_val ) {
-                                       free( mfilter.bv_val );
-                               }
-                       }
-                       mfilter.bv_val = NULL;
-                       mfilter.bv_len = 0;
-#else
-                       mapped_filter = (char *) mfilter.bv_val;
-#endif
-
-                       /*
-                        * Maps required attributes
-                        */
-                       if ( ldap_back_map_attrs(
-                                       &li->targets[ i ]->rwmap.rwm_at,
-                                       new_attrs, 0, &mapped_attrs ) ) {
-                               goto Catch;
-                       }
-
-                       /*
-                        * Starts the search
-                        */
-                       msgid[ i ] = ldap_search( lsc->ld, mbase, realscope,
-                                               mapped_filter, mapped_attrs,
-                                               op->ors_attrsonly );
-
-                       if ( msgid[ i ] == -1 ) {
-                               result->type = CONN_ERR; 
-                               goto Catch; 
-                               /*
-                               lsc->candidate = META_NOT_CANDIDATE;
-                               continue;
-                               */
-                       }
-
-                       if ( mapped_attrs ) {
-                               free( mapped_attrs );
-                               mapped_attrs = NULL;
-                       }
-
-                       if ( mapped_filter != op->ors_filterstr.bv_val ) {
-                               free( mapped_filter );
-                               mapped_filter = NULL;
-                       }
-
-                       if ( mbase != realbase ) {
-                               free( mbase );
-                               mbase = NULL;
-                       }
-
-                       ++candidates;
-               }
-
-               num_entries = handleLdapResult(lc, &op_tmp, rs, msgid,
-                               op->o_bd, attrs,
-                               op->ors_attrsonly, candidates, 
-                               cacheable, &entry_array,
-                               curr_limit, op->ors_slimit, result); 
-
-               if (result->type != SUCCESS) 
-                       goto Catch; 
-               if (cacheable && (num_entries <= curr_limit)) {
-
-#ifdef NEW_LOGGING
-                       LDAP_LOG( BACK_META, DETAIL1,
-                                       "QUERY CACHEABLE\n", 0, 0, 0 );
-#else /* !NEW_LOGGING */
-                       Debug( LDAP_DEBUG_ANY, "QUERY CACHEABLE\n", 0, 0, 0 );
-#endif /* !NEW_LOGGING */
-                       op_tmp.o_bd = li->glue_be;
-                       uuid = cache_entries(&op_tmp, rs, entry_array, cm, result); 
-#ifdef NEW_LOGGING
-                       LDAP_LOG( BACK_META, DETAIL1,
-                                       "Added query %s UUID %s ENTRIES %d\n",
-                                       op->ors_filterstr.bv_val,
-                                       uuid, num_entries );
-#else /* !NEW_LOGGING */
-                       Debug( LDAP_DEBUG_ANY,
-                                       "Added query %s UUID %s ENTRIES %d\n",
-                                       op->ors_filterstr.bv_val,
-                                       uuid, num_entries );
-#endif /* !NEW_LOGGING */
-           
-                       if (result->type != SUCCESS) 
-                               goto Catch; 
-                       (*(qm->addfunc))(qm, &query, template_id, uuid, result); 
-                       if (result->type != SUCCESS) 
-                               goto Catch; 
-                       filter = 0; 
-                       attrs = 0; 
-
-                       /* FIXME : launch do_syncrepl() threads around here
-                        *
-                        * entryUUID and entryCSN need also to be requested by :
-                        */
-                       /*
-                       msgid[ i ] = ldap_search( lsc->ld, mbase, realscope,
-                                               mapped_filter, mapped_attrs, op->ors_attrsonly );
-                       */
-                       /* Also, mbase, realscope, mapped_filter, mapped_attrs need
-                        * be managed as arrays. Each element needs to be retained by this point.
-                        */
-
-               } else {
-#ifdef NEW_LOGGING
-                       LDAP_LOG( BACK_META, DETAIL1,
-                                       "QUERY NOT CACHEABLE no\n",
-                                       0, 0, 0);
-#else /* !NEW_LOGGING */
-                       Debug( LDAP_DEBUG_ANY, "QUERY NOT CACHEABLE no\n",
-                                       0, 0, 0);
-#endif /* !NEW_LOGGING */
-               }
-       }
-
-Catch:;
-       switch (result->type) {
-               case SUCCESS: 
-                       rc = 0; 
-                       break;
-
-               case FILTER_ERR: 
-#ifdef NEW_LOGGING
-                       LDAP_LOG( BACK_META, DETAIL1,
-                                       "Invalid template error\n", 0, 0, 0 );
-#else /* !NEW_LOGGING */
-                       Debug( LDAP_DEBUG_ANY, "Invalid template error\n",
-                                       0, 0, 0 );
-#endif /* !NEW_LOGGING */
-                       break; 
-
-               case CONN_ERR: 
-                       rc = -1; 
-#ifdef NEW_LOGGING
-                       LDAP_LOG( BACK_META, DETAIL1,
-                               "Could not connect to a remote server\n",
-                               0, 0, 0 );
-#else /* !NEW_LOGGING */
-                       Debug( LDAP_DEBUG_ANY,
-                               "Could not connect to a remote server\n",
-                               0, 0, 0 );
-#endif /* !NEW_LOGGING */
-                       send_ldap_error(op, rs, LDAP_OTHER,
-                                       "Connection error" );
-                       break;
-                       
-               case RESULT_ERR: 
-                       rc = -1; 
-#ifdef NEW_LOGGING
-                       LDAP_LOG( BACK_META, DETAIL1,
-                               "Error in handling ldap_result\n", 0, 0, 0 );
-#else /* !NEW_LOGGING */
-                       Debug( LDAP_DEBUG_ANY,
-                               "Error in handling ldap_result\n", 0, 0, 0 );
-#endif /* !NEW_LOGGING */
-                       break; 
-
-               case REWRITING_ERR: 
-                       rc = -1; 
-                       if (result->rc == REWRITE_REGEXEC_UNWILLING) {
-                               send_ldap_error( op, rs,
-                                               LDAP_UNWILLING_TO_PERFORM,
-                                               "Unwilling to perform" );
-                       } else {
-                               send_ldap_error( op, rs, LDAP_OTHER,
-                                               "Rewrite error" );
-                       }
-                       break;
-
-               case MERGE_ERR: 
-                       rc = -1; 
-#ifdef NEW_LOGGING
-                       LDAP_LOG( BACK_META, DETAIL1,
-                               "Error in merging entry \n", 0, 0, 0 );
-#else /* !NEW_LOGGING */
-                       Debug( LDAP_DEBUG_ANY,
-                               "Error in merging entry \n", 0, 0, 0 );
-#endif /* !NEW_LOGGING */
-                       break;
-
-               case REMOVE_ERR: 
-                       rc = -1; 
-#ifdef NEW_LOGGING
-                       LDAP_LOG( BACK_META, DETAIL1,
-                                       "Error in removing query \n",
-                                       0, 0, 0 );
-#else /* !NEW_LOGGING */
-                       Debug( LDAP_DEBUG_ANY, "Error in removing query \n",
-                                       0, 0, 0 );
-#endif /* !NEW_LOGGING */
-                       break;
-
-               default:
-                       /* assert(0); */
-                       break;
-       }
-
-
-       if ( msgid ) {
-               ch_free( msgid );
-       }
-       if (entry_array)  {
-               for (i=0; (e = entry_array[i]); i++) {
-                       entry_free(e); 
-               }
-               free(entry_array);
-       }
-       if (filter) 
-               filter_free(filter);
-
-       if (new_attrs) {
-               if (new_attrs != attrs) 
-                       free(new_attrs); 
-       }
-
-       if (attrs)
-               free(attrs); 
-
-       if (tempstr.bv_val ) {
-               free(tempstr.bv_val);
-       }
-       ldap_pvt_thread_mutex_lock(&cm->cache_mutex); 
-       cm->threads--; 
-#ifdef NEW_LOGGING
-       LDAP_LOG( BACK_META, DETAIL1, "Threads-- = %d\n", cm->threads, 0, 0 ); 
-#else /* !NEW_LOGGING */
-       Debug( LDAP_DEBUG_ANY, "Threads-- = %d\n", cm->threads, 0, 0 ); 
-#endif /* !NEW_LOGGING */
-       ldap_pvt_thread_mutex_unlock(&cm->cache_mutex); 
-       return rc;
-}
-
-
-static Entry* 
-meta_create_entry (
-       Backend                 *be,
-       struct metaconn         *lc,
-       int                     target,
-       LDAPMessage             *e,
-       struct exception*       result
-)
-{
-       struct metainfo         *li = ( struct metainfo * )be->be_private;
-       struct berval           a, mapped;
-       Entry*                  ent;
-       BerElement              ber = *e->lm_ber;
-       Attribute               *attr, *soc_attr, **attrp;
-       struct berval   dummy = { 0, NULL };
-       struct berval   *bv, bdn;
-       const char              *text = NULL;
-       char*                   ename = NULL; 
-       struct berval   sc = { 0, NULL };
-       char                    textbuf[SLAP_TEXT_BUFLEN];
-       size_t                  textlen = sizeof(textbuf);
-
-       if ( ber_scanf( &ber, "{m{", &bdn ) == LBER_ERROR ) {
-               result->type = CREATE_ENTRY_ERR;        
-               return NULL; 
-       }
-       ent = (Entry*)malloc(sizeof(Entry)); 
-
-       /*
-        * Rewrite the dn of the result, if needed
-        */
-       rewriteSession( li->targets[ target ]->rwmap.rwm_rw, "searchResult",
-                       bdn.bv_val, lc->conn, &ent->e_name.bv_val, result );  
-
-       if (result->type != SUCCESS) {
-               return NULL; 
-       }
-       if ( ent->e_name.bv_val == NULL ) {
-               ber_dupbv(&(ent->e_name), &bdn);
-       } else {
-#ifdef NEW_LOGGING
-               LDAP_LOG( BACK_META, DETAIL1,
-                       "[rw] searchResult[%d]: \"%s\" -> \"%s\"\n",
-                       target, bdn.bv_val, ent->e_name.bv_val );
-#else /* !NEW_LOGGING */
-               Debug( LDAP_DEBUG_ARGS, "rw> searchResult[%d]: \"%s\""
-                       " -> \"%s\"\n",
-                       target, bdn.bv_val, ent->e_name.bv_val );
-#endif /* !NEW_LOGGING */
-               ent->e_name.bv_len = strlen( ent->e_name.bv_val );
-       }
-               
-       /*
-        * Note: this may fail if the target host(s) schema differs
-        * from the one known to the meta, and a DN with unknown
-        * attributes is returned.
-        * 
-        * FIXME: should we log anything, or delegate to dnNormalize?
-        */
-       dnNormalize( 0, NULL, NULL, &ent->e_name, &ent->e_nname, NULL ); 
-
-       /*
-       if ( dnNormalize( 0, NULL, NULL, &ent->e_name, &ent->e_nname )
-               != LDAP_SUCCESS )
-       {
-               return LDAP_INVALID_DN_SYNTAX;
-       }
-       */
-
-       /*
-        * cache dn
-        */
-       if ( li->cache.ttl != META_DNCACHE_DISABLED ) {
-               meta_dncache_update_entry( &li->cache, &ent->e_nname, target );
-       }
-
-       ent->e_id = 0;
-       ent->e_attrs = 0;
-       ent->e_private = 0;
-        ent->e_bv.bv_val = 0; 
-
-       attrp = &ent->e_attrs;
-
-       while ( ber_scanf( &ber, "{m", &a ) != LBER_ERROR ) {
-               ldap_back_map( &li->targets[ target ]->rwmap.rwm_at, 
-                               &a, &mapped, 1 );
-               if ( mapped.bv_val == NULL ) {
-                       continue;
-               }
-               attr = ( Attribute * )ch_malloc( sizeof( Attribute ) );
-               if ( attr == NULL ) {
-                       continue;
-               }
-               attr->a_flags = 0;
-               attr->a_next = 0;
-               attr->a_desc = NULL;
-               attr->a_nvals = NULL;
-               if ( slap_bv2ad( &mapped, &attr->a_desc, &text ) != LDAP_SUCCESS) {
-                       if ( slap_bv2undef_ad( &mapped, &attr->a_desc, &text ) 
-                                       != LDAP_SUCCESS) {
-#ifdef NEW_LOGGING
-                               LDAP_LOG( BACK_META, DETAIL1,
-                                       "slap_bv2undef_ad(%s): %s\n",
-                                       mapped.bv_val, text, 0 );
-#else /* !NEW_LOGGING */
-                               Debug( LDAP_DEBUG_ANY,
-                                       "slap_bv2undef_ad(%s): "
-                                       "%s\n%s", mapped.bv_val, text, "" );
-#endif /* !NEW_LOGGING */
-                               ch_free( attr );
-                               continue;
-                       }
-               }
-
-               /* no subschemaSubentry */
-               if ( attr->a_desc == slap_schema.si_ad_subschemaSubentry ) {
-                       ch_free(attr);
-                       continue;
-               }
-
-               if ( ber_scanf( &ber, "[W]", &attr->a_vals ) == LBER_ERROR 
-                               || attr->a_vals == NULL ) {
-                       attr->a_vals = &dummy;
-#if 0
-               } else if ( attr->a_desc == slap_schema.si_ad_objectClass ||
-                               attr->a_desc ==
-                               slap_schema.si_ad_structuralObjectClass) {
-#else
-               } else if ( attr->a_desc == slap_schema.si_ad_objectClass ) {
-#endif
-                       int i, last;
-                       for ( last = 0; attr->a_vals[ last ].bv_val; ++last )
-                               ;
-                       for ( i = 0, bv = attr->a_vals; bv->bv_val; bv++,i++ ) {
-                               ldap_back_map( &li->targets[ target]->rwmap.rwm_oc,
-                                               bv, &mapped, 1 );
-                               if ( mapped.bv_val == NULL ) {
-                                       free( bv->bv_val );
-                                       bv->bv_val = NULL;
-                                       if ( --last < 0 ) {
-                                               break;
-                                       }
-                                       *bv = attr->a_vals[ last ];
-                                       attr->a_vals[ last ].bv_val = NULL;
-                                       i--;
-                               } else if ( mapped.bv_val != bv->bv_val ) {
-                                       free( bv->bv_val );
-                                       ber_dupbv( bv, &mapped );
-                               }
-                       }
-
-                       structural_class( attr->a_vals, &sc, NULL, &text, textbuf, textlen );
-                       soc_attr = (Attribute*) ch_malloc( sizeof( Attribute ));
-                       soc_attr->a_desc = slap_schema.si_ad_structuralObjectClass;
-                       soc_attr->a_vals = (BerVarray) ch_malloc( 2* sizeof( BerValue ));
-                       ber_dupbv( &soc_attr->a_vals[0], &sc );
-                       soc_attr->a_vals[1].bv_len = 0;
-                       soc_attr->a_vals[1].bv_val = NULL;
-                       soc_attr->a_nvals = (BerVarray) ch_malloc( 2* sizeof( BerValue ));
-                       ber_dupbv( &soc_attr->a_nvals[0], &sc );
-                       soc_attr->a_nvals[1].bv_len = 0;
-                       soc_attr->a_nvals[1].bv_val = NULL;
-
-                       *attrp = soc_attr;
-                       attrp = &soc_attr->a_next;
-
-               /*
-                * It is necessary to try to rewrite attributes with
-                * dn syntax because they might be used in ACLs as
-                * members of groups; since ACLs are applied to the
-                * rewritten stuff, no dn-based subecj clause could
-                * be used at the ldap backend side (see
-                * http://www.OpenLDAP.org/faq/data/cache/452.html)
-                * The problem can be overcome by moving the dn-based
-                * ACLs to the target directory server, and letting
-                * everything pass thru the ldap backend.
-                */
-               } else if ( strcmp( attr->a_desc->ad_type->sat_syntax->ssyn_oid,
-                               SLAPD_DN_SYNTAX ) == 0 ) {
-                       int i;
-                       for ( i = 0, bv = attr->a_vals; bv->bv_val; bv++,i++ ) {
-                               char *newval;
-                               rewriteSession(li->targets[ target ]->rwmap.rwm_rw,
-                                               "searchResult", bv->bv_val,
-                                               lc->conn, &newval, result); 
-                               if (result->type != SUCCESS) {
-                                       /* FIXME : Handle error */
-                                       result->type = SUCCESS; 
-                               } else {
-                                       /* left as is */
-                                       if ( newval == NULL ) {
-                                               break;
-                                       }
-#ifdef NEW_LOGGING
-                                       LDAP_LOG( BACK_META, DETAIL1,
-                                               "[rw] searchResult on "
-                                               "attr=%s: \"%s\" -> \"%s\"\n",
-                                               attr->a_desc->ad_type->
-                                               sat_cname.bv_val,
-                                               bv->bv_val, newval );
-#else /* !NEW_LOGGING */
-                                       Debug( LDAP_DEBUG_ARGS,
-                                               "rw> searchResult on attr=%s:"
-                                               " \"%s\" -> \"%s\"\n",
-                                               attr->a_desc->ad_type->
-                                               sat_cname.bv_val,
-                                               bv->bv_val, newval );
-#endif /* !NEW_LOGGING */
-                                       free( bv->bv_val );
-                                       bv->bv_val = newval;
-                                       bv->bv_len = strlen( newval );
-                               }
-                       }
-               }
-               *attrp = attr;
-               attrp = &attr->a_next;
-       }
-
-       return ent; 
-}
-
-static int
-is_one_level_rdn(
-       const char      *rdn,
-       int             from
-)
-{
-       for ( ; from--; ) {
-               if ( DN_SEPARATOR( rdn[ from ] ) ) {
-                       return 0;
-               }
-       }
-       return 1;
-}
-
-static struct metaconn*  
-metaConnect(
-       Operation*              op, 
-       SlapReply               *rs,
-       int                     op_type, 
-       struct berval           *nbase, 
-       struct exception        *result)
-{
-       struct metaconn         *lc; 
-
-       result->type = SUCCESS; 
-       lc = meta_back_getconn( op, rs, op_type, nbase, NULL );
-       if (!lc) {
-               result->type = CONN_ERR; 
-               return 0; 
-       }
-       return lc; 
-}
-
-static void
-add_filter_attrs(
-       AttributeName** new_attrs, 
-       AttributeName* attrs, 
-       AttributeName* filter_attrs )
-{
-       struct berval all_user = { sizeof(LDAP_ALL_USER_ATTRIBUTES) -1,
-                                  LDAP_ALL_USER_ATTRIBUTES };
-
-       struct berval all_op = { sizeof(LDAP_ALL_OPERATIONAL_ATTRIBUTES) -1,
-                                       LDAP_ALL_OPERATIONAL_ATTRIBUTES}; 
-
-       int alluser = 0; 
-       int allop = 0; 
-       int i; 
-       int count; 
-
-       /* duplicate attrs */
-        if (attrs == NULL) {
-               count = 1; 
-       } else { 
-               for (count=0; attrs[count].an_name.bv_val; count++) 
-                       ;
-       }
-       *new_attrs = (AttributeName*)(malloc((count+1)*sizeof(AttributeName))); 
-       if (attrs == NULL) { 
-               (*new_attrs)[0].an_name.bv_val = "*"; 
-               (*new_attrs)[0].an_name.bv_len = 1; 
-               (*new_attrs)[1].an_name.bv_val = NULL;
-               (*new_attrs)[1].an_name.bv_len = 0; 
-               alluser = 1; 
-               allop = 0; 
-       } else {  
-               for (i=0; i<count; i++) {
-                       (*new_attrs)[i].an_name = attrs[i].an_name; 
-                       (*new_attrs)[i].an_desc = attrs[i].an_desc;  
-               }
-               (*new_attrs)[count].an_name.bv_val = NULL; 
-               (*new_attrs)[count].an_name.bv_len = 0; 
-               alluser = an_find(*new_attrs, &all_user); 
-               allop = an_find(*new_attrs, &all_op); 
-       }
-
-       for ( i=0; filter_attrs[i].an_name.bv_val; i++ ) {
-               if ( an_find(*new_attrs, &filter_attrs[i].an_name ))
-                       continue; 
-               if ( is_at_operational(filter_attrs[i].an_desc->ad_type) ) {
-                       if (allop) 
-                               continue; 
-               } else if (alluser) 
-                       continue; 
-               *new_attrs = (AttributeName*)(realloc(*new_attrs,
-                                       (count+2)*sizeof(AttributeName))); 
-               (*new_attrs)[count].an_name.bv_val =
-                               filter_attrs[i].an_name.bv_val; 
-               (*new_attrs)[count].an_name.bv_len =
-                               filter_attrs[i].an_name.bv_len; 
-               (*new_attrs)[count].an_desc = filter_attrs[i].an_desc; 
-               (*new_attrs)[count+1].an_name.bv_val = NULL; 
-               (*new_attrs)[count+1].an_name.bv_len = 0; 
-               count++; 
-       }
-}
-
-static int 
-handleLdapResult(
-       struct metaconn* lc,
-       Operation* op, 
-       SlapReply *rs,
-       int* msgid, Backend* be, 
-       AttributeName* attrs, 
-       int attrsonly, 
-       int candidates, 
-       int cacheable, 
-       Entry*** entry_array, 
-       int curr_limit, 
-       int slimit,
-       struct exception* result)
-{
-       Entry  *entry;
-       char *match = NULL, *err = NULL, *cache_ename = NULL;
-       int sres; 
-       int mres = LDAP_SUCCESS; 
-       int num_entries = 0, count, i, rc;     
-       struct timeval tv = {0, 0}; 
-       struct metasingleconn* lsc; 
-       struct metainfo         *li = ( struct metainfo * )be->be_private;
-       result->rc = 0; 
-       result->type = SUCCESS; 
-
-       for ( count = 0, rc = 0; candidates > 0; ) {
-               int ab, gotit = 0;
-
-               /* check for abandon */
-               ab = op->o_abandon;
-
-               for ( i = 0, lsc = lc->conns; !META_LAST(lsc); lsc++, i++ ) {
-                       if ( lsc->candidate != META_CANDIDATE ) {
-                               continue;
-                       }
-
-                       if ( ab ) {
-                               ldap_abandon( lsc->ld, msgid[ i ] );
-                               result->type = ABANDON_ERR;
-                               break; 
-                       }
-
-                       if ( slimit > 0 && num_entries == slimit ) {
-                               result->type = SLIMIT_ERR; 
-                               break; 
-                       }
-
-                       if ((entry = get_result_entry(be, lc, lsc,
-                                               msgid, i, &tv, result))) {
-                               rs->sr_entry = entry;
-                               rs->sr_attrs = op->ors_attrs; 
-                               send_search_entry( op, rs );
-                               rs->sr_entry = NULL;
-                               rs->sr_attrs = NULL; 
-                               if ((cacheable) &&
-                                               (num_entries < curr_limit))  {
-                                       rewriteSession( li->rwinfo,
-                                                       "cacheResult",
-                                                       entry->e_name.bv_val,
-                                                       lc->conn,
-                                                       &cache_ename, result );  
-                                       free(entry->e_name.bv_val); 
-                                       if (result->type != SUCCESS) {
-                                               return 0; 
-                                       }
-                                       ber_str2bv(cache_ename,
-                                               strlen(cache_ename),
-                                               0, &entry->e_name); 
-                                       ber_dupbv(&entry->e_nname,
-                                               &entry->e_name); 
-                                       *entry_array = (Entry**)realloc(
-                                                       *entry_array,
-                                                       (( num_entries+2 ) *
-                                                        sizeof( Entry* )));
-                                       (*entry_array)[num_entries] = entry;    
-                                       (*entry_array)[num_entries+1] = NULL;
-                               }
-                               num_entries++; 
-                               gotit = 1; 
-                       } else if (result->type == REWRITING_ERR) {
-                               return 0; 
-                       } else if (result->type == TIMEOUT_ERR) {
-                               result->type = SUCCESS; 
-                               continue;  
-                       } else if (result->type == CREATE_ENTRY_ERR) {
-                               break; 
-                       } else if (result->rc == -1) {
-                               break; 
-                       } else {
-                               rs->sr_err = result->rc;
-                               sres = ldap_back_map_result(rs);
-                               if (mres == LDAP_SUCCESS &&
-                                               sres != LDAP_SUCCESS) {
-                                       mres = sres; 
-                                       ldap_get_option(lsc->ld,
-                                               LDAP_OPT_ERROR_STRING, &err);
-                                       ldap_get_option(lsc->ld,
-                                               LDAP_OPT_MATCHED_DN, &match);
-                               }
-                               lsc->candidate = META_NOT_CANDIDATE; 
-                               candidates--; 
-                               result->type = SUCCESS; 
-                       }
-               }
-               switch (result->type) {
-               case RESULT_ERR: 
-#ifdef NEW_LOGGING
-                       LDAP_LOG( BACK_META, DETAIL1,
-                                       "ldap_result error, rc = -1\n",
-                                       0, 0, 0 );
-#else /* !NEW_LOGGING */
-                       Debug( LDAP_DEBUG_ANY, "ldap_result error, rc = -1\n",
-                                       0, 0, 0 );
-#endif /* !NEW_LOGGING */
-                       rs->sr_err = LDAP_OTHER;
-                       send_ldap_result( op, rs );
-                       return 0; 
-
-               case CREATE_ENTRY_ERR: 
-#ifdef NEW_LOGGING
-                       LDAP_LOG( BACK_META, DETAIL1,
-                                       "Error in parsing result \n",
-                                       0, 0, 0 );
-#else /* !NEW_LOGGING */
-                       Debug( LDAP_DEBUG_ANY, "Error in parsing result \n",
-                                       0, 0, 0 );
-#endif /* !NEW_LOGGING */
-                       rs->sr_err = LDAP_OTHER;
-                       send_ldap_result( op, rs );
-                       result->type = RESULT_ERR; 
-                       return 0; 
-
-               case SLIMIT_ERR: 
-#ifdef NEW_LOGGING
-                       LDAP_LOG( BACK_META, DETAIL1, "Size limit exceeded \n",
-                                       0, 0, 0 );
-#else /* !NEW_LOGGING */
-                       Debug( LDAP_DEBUG_ANY, "Size limit exceeded \n",
-                                       0, 0, 0 );
-#endif /* !NEW_LOGGING */
-                       rs->sr_err = LDAP_SIZELIMIT_EXCEEDED;
-                       send_ldap_result( op, rs );
-                       result->type = RESULT_ERR; 
-                       return 0;
-
-               case ABANDON_ERR: 
-#ifdef NEW_LOGGING
-                       LDAP_LOG( BACK_META, DETAIL1,
-                                       "search operation abandoned \n",
-                                       0, 0, 0 );
-#else /* !NEW_LOGGING */
-                       Debug( LDAP_DEBUG_ANY, "search operation abandoned \n",
-                                       0, 0, 0 );
-#endif /* !NEW_LOGGING */
-                       result->type = RESULT_ERR; 
-                       return 0; 
-
-               default:
-                       /* assert( 0 ); */
-                       break;
-               }
-               if ( gotit == 0 ) {
-                       tv.tv_sec = 0;
-                       tv.tv_usec = 100000;
-                       ldap_pvt_thread_yield();
-               } else {
-                       tv.tv_sec = 0;
-                       tv.tv_usec = 0;
-               }
-       }
-
-       rs->sr_err = mres;
-       rs->sr_text = err;
-       rs->sr_matched = match;
-
-       send_ldap_result( op, rs );
-
-       rs->sr_text = NULL;
-       rs->sr_matched = NULL;
-
-       if (err) 
-               free(err); 
-
-       if (match) 
-               free(match); 
-    
-       result->type = (mres == LDAP_SUCCESS) ? SUCCESS : RESULT_ERR; 
-       return num_entries; 
-}
-
-static Entry* 
-get_result_entry(
-       Backend* be, 
-       struct metaconn* lc, 
-       struct metasingleconn* lsc, 
-       int* msgid,
-       int i, 
-       struct timeval* tv, 
-       struct exception* result)
-{
-       Entry* entry; 
-       LDAPMessage     *res, *e; 
-       int rc; 
-       int sres = LDAP_SUCCESS; 
-
-       rc = ldap_result( lsc->ld, msgid[ i ],
-                       0, tv, &res );
-
-       if ( rc == 0 ) {
-               result->type = TIMEOUT_ERR; 
-               return NULL; 
-       } else if ( rc == -1 ) {
-               result->rc = -1; 
-               result->type = RESULT_ERR; 
-               return NULL; 
-       } else if ( rc == LDAP_RES_SEARCH_ENTRY ) {
-               e = ldap_first_entry( lsc->ld, res );
-               entry = meta_create_entry(be, lc, i, e, result);  
-               if (!entry) {
-                       return NULL; 
-               }    
-               ldap_msgfree( res );
-               result->type = SUCCESS; 
-               return entry; 
-       } else {
-               sres = ldap_result2error( lsc->ld,
-                               res, 1 );
-               result->rc = sres; 
-               result->type = RESULT_ERR; 
-               return NULL; 
-       }
-}      
-
-static void
-rewriteSession(
-       struct rewrite_info* info, 
-       const char* rewriteContext, 
-       const char* string, 
-       const void* cookie,  
-       char** base, 
-       struct exception* result)
-{
-       int rc = rewrite_session(info, rewriteContext, string, cookie, base); 
-       if (rc != REWRITE_REGEXEC_OK) {
-               result->rc = rc; 
-               result->type = REWRITING_ERR; 
-
-               if (strcmp(rewriteContext, "searchBase") == 0) 
-#ifdef NEW_LOGGING
-                       LDAP_LOG( BACK_META, DETAIL1,
-                               "Problem in rewriting search base\n", 0, 0, 0 );
-#else /* !NEW_LOGGING */
-                       Debug( LDAP_DEBUG_ANY,
-                               "Problem in rewriting search base\n", 0, 0, 0 );
-#endif /* !NEW_LOGGING */
-               if (strcmp(rewriteContext, "searchFilter") == 0) 
-#ifdef NEW_LOGGING
-                       LDAP_LOG( BACK_META, DETAIL1,
-                               "Problem in rewriting search filter\n",
-                               0, 0, 0 );
-#else /* !NEW_LOGGING */
-                       Debug( LDAP_DEBUG_ANY,
-                               "Problem in rewriting search filter\n",
-                               0, 0, 0 );
-#endif /* !NEW_LOGGING */
-               if (strcmp(rewriteContext, "searchResult") == 0) 
-#ifdef NEW_LOGGING
-                       LDAP_LOG( BACK_META, DETAIL1,
-                               "Problem in rewriting DN, or DN syntax "
-                               "attributes of search result\n", 0, 0, 0 );
-#else /* !NEW_LOGGING */
-                       Debug( LDAP_DEBUG_ANY,
-                               "Problem in rewriting DN, or DN syntax "
-                               "attributes of search result\n", 0, 0, 0 );
-#endif /* !NEW_LOGGING */
-               if (strcmp(rewriteContext, "cacheBase") == 0) 
-#ifdef NEW_LOGGING
-                       LDAP_LOG( BACK_META, DETAIL1,
-                               "Problem in rewriting search base with "
-                               "cache base\n", 0, 0, 0 );
-#else /* !NEW_LOGGING */
-                       Debug( LDAP_DEBUG_ANY,
-                               "Problem in rewriting search base with "
-                               "cache base\n", 0, 0, 0 );
-#endif /* !NEW_LOGGING */
-               if (strcmp(rewriteContext, "cacheResult") == 0) 
-#ifdef NEW_LOGGING
-                       LDAP_LOG( BACK_META, DETAIL1,
-                               "Problem in rewriting DN for cached entries\n",
-                               0, 0, 0 );
-#else /* !NEW_LOGGING */
-                       Debug( LDAP_DEBUG_ANY,
-                               "Problem in rewriting DN for cached entries\n",
-                               0, 0, 0 );
-#endif /* !NEW_LOGGING */
-               if (strcmp(rewriteContext, "cacheReturn") == 0) 
-#ifdef NEW_LOGGING
-                       LDAP_LOG( BACK_META, DETAIL1,
-                               "Problem in rewriting DN for answerable "
-                               "entries\n", 0, 0, 0 );
-#else /* !NEW_LOGGING */
-                       Debug( LDAP_DEBUG_ANY,
-                               "Problem in rewriting DN for answerable "
-                               "entries\n", 0, 0, 0 );
-#endif /* !NEW_LOGGING */
-       } else {
-               result->type = SUCCESS;
-       }
-}
-
-static int 
-get_attr_set(
-       AttributeName* attrs, 
-       query_manager* qm, 
-       int num )
-{
-       int i; 
-       for (i=0; i<num; i++) {
-               if (attrscmp(attrs, qm->attr_sets[i].attrs)) 
-                       return i;
-       }
-       return -1; 
-}
-
-static int 
-attrscmp(
-       AttributeName* attrs_in, 
-       AttributeName* attrs)
-{
-       int i, count1, count2; 
-       if ( attrs_in == NULL ) {
-               return (attrs ? 0 : 1); 
-       } 
-       if ( attrs == NULL ) 
-               return 0; 
-       
-       for ( count1=0;
-             attrs_in && attrs_in[count1].an_name.bv_val != NULL;
-             count1++ )
-               ;
-       for ( count2=0;
-             attrs && attrs[count2].an_name.bv_val != NULL;
-             count2++) 
-               ;
-       if ( count1 != count2 )
-               return 0; 
-
-       for ( i=0; i<count1; i++ ) {
-               if ( !an_find(attrs, &attrs_in[i].an_name ))
-                       return 0; 
-       }
-       return 1; 
-}
-
-static char* 
-cache_entries(
-       Operation       *op,
-       SlapReply       *rs,
-       Entry** entry_array, 
-       cache_manager* cm, 
-       struct exception* result)
-{
-       int             i; 
-       int             return_val; 
-       int             cache_size; 
-       Entry           *e; 
-       struct berval   query_uuid; 
-       struct berval   crp_uuid; 
-       char            uuidbuf[ LDAP_LUTIL_UUIDSTR_BUFSIZE ], *crpid; 
-       char            crpuuid[40]; 
-       query_manager   *qm = cm->qm;
-    
-       result->type = SUCCESS; 
-       query_uuid.bv_len = lutil_uuidstr(uuidbuf, sizeof(uuidbuf)); 
-       query_uuid.bv_val = ch_strdup(uuidbuf);
-
-#ifdef NEW_LOGGING
-       LDAP_LOG( BACK_META, DETAIL1, "UUID for query being added = %s\n",
-                       uuidbuf, 0, 0 );
-#else /* !NEW_LOGGING */
-       Debug( LDAP_DEBUG_ANY, "UUID for query being added = %s\n",
-                       uuidbuf, 0, 0 );
-#endif /* !NEW_LOGGING */
-       
-       for ( i=0; ( entry_array && (e=entry_array[i]) ); i++ ) {
-#ifdef NEW_LOGGING
-               LDAP_LOG( BACK_META, DETAIL2, "LOCKING REMOVE MUTEX\n",
-                               0, 0, 0 );
-#else /* !NEW_LOGGING */
-               Debug( LDAP_DEBUG_NONE, "LOCKING REMOVE MUTEX\n", 0, 0, 0 );
-#endif /* !NEW_LOGGING */
-               ldap_pvt_thread_mutex_lock(&cm->remove_mutex); 
-#ifdef NEW_LOGGING
-               LDAP_LOG( BACK_META, DETAIL2, "LOCKED REMOVE MUTEX\n", 0, 0, 0);
-#else /* !NEW_LOGGING */
-               Debug( LDAP_DEBUG_NONE, "LOCKED REMOVE MUTEX\n", 0, 0, 0);
-#endif /* !NEW_LOGGING */
-               if ( cm->cache_size > (cm->thresh_hi) ) {
-                       while(cm->cache_size > (cm->thresh_lo)) {
-                               crpid = cache_replacement(qm);
-                               if (crpid == NULL) {
-                                       result->type = REMOVE_ERR; 
-                               } else {
-                                       strcpy(crpuuid, crpid); 
-                                       crp_uuid.bv_val = crpuuid; 
-                                       crp_uuid.bv_len = strlen(crpuuid); 
-#ifdef NEW_LOGGING
-                                       LDAP_LOG( BACK_META, DETAIL1,
-                                               "Removing query UUID %s\n",
-                                               crpuuid, 0, 0 );
-#else /* !NEW_LOGGING */
-                                       Debug( LDAP_DEBUG_ANY,
-                                               "Removing query UUID %s\n",
-                                               crpuuid, 0, 0 );
-#endif /* !NEW_LOGGING */
-                                       return_val = remove_query_data(op, rs,
-                                                       &crp_uuid, result); 
-#ifdef NEW_LOGGING
-                                       LDAP_LOG( BACK_META, DETAIL1,
-                                               "QUERY REMOVED, SIZE=%d\n",
-                                               return_val, 0, 0);
-#else /* !NEW_LOGGING */
-                                       Debug( LDAP_DEBUG_ANY,
-                                               "QUERY REMOVED, SIZE=%d\n",
-                                               return_val, 0, 0);
-#endif /* !NEW_LOGGING */
-                                       ldap_pvt_thread_mutex_lock(
-                                                       &cm->cache_mutex ); 
-                                       cm->total_entries -= result->rc; 
-                                       cm->num_cached_queries--; 
-#ifdef NEW_LOGGING
-                                       LDAP_LOG( BACK_META, DETAIL1,
-                                               "STORED QUERIES = %lu\n",
-                                               cm->num_cached_queries, 0, 0 );
-#else /* !NEW_LOGGING */
-                                       Debug( LDAP_DEBUG_ANY,
-                                               "STORED QUERIES = %lu\n",
-                                               cm->num_cached_queries, 0, 0 );
-#endif /* !NEW_LOGGING */
-                                       ldap_pvt_thread_mutex_unlock(
-                                                       &cm->cache_mutex );
-                                       cm->cache_size = (return_val >
-                                               cm->cache_size) ?
-                                               0 : (cm->cache_size-return_val);
-#ifdef NEW_LOGGING
-                                       LDAP_LOG( BACK_META, DETAIL1,
-                                               "QUERY REMOVED, CACHE SIZE="
-                                               "%lu bytes %d entries\n",
-                                               cm->cache_size,
-                                               cm->total_entries, 0 );
-#else /* !NEW_LOGGING */
-                                       Debug( LDAP_DEBUG_ANY,
-                                               "QUERY REMOVED, CACHE SIZE="
-                                               "%lu bytes %d entries\n",
-                                               cm->cache_size,
-                                               cm->total_entries, 0 );
-#endif /* !NEW_LOGGING */
-                               }
-                       }
-               }
-
-               rs->sr_entry = e;
-               return_val = merge_entry(op, rs, &query_uuid, result);
-               rs->sr_entry = NULL;
-               cm->cache_size += return_val;
-#ifdef NEW_LOGGING
-               LDAP_LOG( BACK_META, DETAIL1,
-                       "ENTRY ADDED/MERGED, CACHE SIZE=%lu bytes\n",
-                       cm->cache_size, 0, 0 );
-#else /* !NEW_LOGGING */
-               Debug( LDAP_DEBUG_ANY,
-                       "ENTRY ADDED/MERGED, CACHE SIZE=%lu bytes\n",
-                       cm->cache_size, 0, 0 );
-#endif /* !NEW_LOGGING */
-#ifdef NEW_LOGGING
-               LDAP_LOG( BACK_META, DETAIL2, "UNLOCKING REMOVE MUTEX\n",
-                               0, 0, 0 );
-#else /* !NEW_LOGGING */
-               Debug( LDAP_DEBUG_NONE, "UNLOCKING REMOVE MUTEX\n", 0, 0, 0 );
-#endif /* !NEW_LOGGING */
-               ldap_pvt_thread_mutex_unlock(&cm->remove_mutex); 
-#ifdef NEW_LOGGING
-               LDAP_LOG( BACK_META, DETAIL2, "UNLOCKED REMOVE MUTEX\n",
-                               0, 0, 0 );
-#else /* !NEW_LOGGING */
-               Debug( LDAP_DEBUG_NONE, "UNLOCKED REMOVE MUTEX\n", 0, 0, 0 );
-#endif /* !NEW_LOGGING */
-               if (result->type != SUCCESS) 
-                       return 0; 
-               ldap_pvt_thread_mutex_lock(&cm->cache_mutex); 
-               cm->total_entries += result->rc; 
-#ifdef NEW_LOGGING
-               LDAP_LOG( BACK_META, DETAIL1,
-                       "ENTRY ADDED/MERGED, SIZE=%d, CACHED ENTRIES=%d\n",
-                       return_val, cm->total_entries, 0 );
-#else /* !NEW_LOGGING */
-               Debug( LDAP_DEBUG_ANY,
-                       "ENTRY ADDED/MERGED, SIZE=%d, CACHED ENTRIES=%d\n",
-                       return_val, cm->total_entries, 0 );
-#endif /* !NEW_LOGGING */
-               ldap_pvt_thread_mutex_unlock(&cm->cache_mutex); 
-       }
-       ldap_pvt_thread_mutex_lock(&cm->cache_mutex); 
-       cm->num_cached_queries++; 
-#ifdef NEW_LOGGING
-       LDAP_LOG( BACK_META, DETAIL1, "STORED QUERIES = %lu\n",
-                       cm->num_cached_queries, 0, 0 );
-#else /* !NEW_LOGGING */
-       Debug( LDAP_DEBUG_ANY, "STORED QUERIES = %lu\n",
-                       cm->num_cached_queries, 0, 0 );
-#endif /* !NEW_LOGGING */
-       ldap_pvt_thread_mutex_unlock(&cm->cache_mutex); 
-
-       return query_uuid.bv_val; 
-}
-
-static int 
-is_temp_answerable(
-       int attr_set, 
-       struct berval* tempstr, 
-       query_manager* qm, 
-       int template_id )
-{
-       int i; 
-       int* id_array; 
-       char* str;
-       int result = 0; 
-       i = qm->templates[template_id].attr_set_index; 
-       str = qm->templates[template_id].querystr; 
-
-       if (attr_set == i) {
-               result = 1; 
-       } else { 
-               id_array = qm->attr_sets[attr_set].ID_array;    
-
-               while (*id_array != -1) {
-                       if (*id_array == i) 
-                               result = 1; 
-                       id_array++; 
-               }
-       }
-       if (!result) 
-               return 0; 
-       if (strcasecmp(str, tempstr->bv_val) == 0)  
-               return 1; 
-       return 0; 
-}
-
-static void* 
-consistency_check(void* operation)
-{
-       Operation* op = (Operation*)operation; 
-
-       SlapReply rs = {REP_RESULT}; 
-
-       struct metainfo *li = ( struct metainfo * )op->o_bd->be_private;
-       cache_manager*  cm = li->cm; 
-       query_manager* qm = cm->qm; 
-       CachedQuery* query, *query_prev; 
-       time_t curr_time; 
-       struct berval uuid;  
-       struct exception result; 
-       int i, return_val; 
-       QueryTemplate* templ;
-
-
-       op->o_bd = li->glue_be;
-      
-        for(;;) {
-               ldap_pvt_thread_sleep(cm->cc_period);     
-               for (i=0; qm->templates[i].querystr; i++) {
-                       templ = qm->templates + i; 
-                       query = templ->query_last; 
-                       curr_time = slap_get_time(); 
-                       ldap_pvt_thread_mutex_lock(&cm->remove_mutex); 
-                       while (query && (query->expiry_time < curr_time)) {
-                               ldap_pvt_thread_mutex_lock(&qm->lru_mutex); 
-                               remove_query(qm, query); 
-                               ldap_pvt_thread_mutex_unlock(&qm->lru_mutex); 
-#ifdef NEW_LOGGING
-                               LDAP_LOG( BACK_META, DETAIL1, "Lock CR index = %d\n",
-                                               i, 0, 0 );
-#else /* !NEW_LOGGING */
-                               Debug( LDAP_DEBUG_ANY, "Lock CR index = %d\n",
-                                               i, 0, 0 );
-#endif /* !NEW_LOGGING */
-                               ldap_pvt_thread_rdwr_wlock(&templ->t_rwlock);  
-                               remove_from_template(query, templ); 
-#ifdef NEW_LOGGING
-                               LDAP_LOG( BACK_META, DETAIL1,
-                                               "TEMPLATE %d QUERIES-- %d\n",
-                                               i, templ->no_of_queries, 0 );
-#else /* !NEW_LOGGING */
-                               Debug( LDAP_DEBUG_ANY, "TEMPLATE %d QUERIES-- %d\n",
-                                               i, templ->no_of_queries, 0 );
-#endif /* !NEW_LOGGING */
-#ifdef NEW_LOGGING
-                               LDAP_LOG( BACK_META, DETAIL1, "Unlock CR index = %d\n",
-                                               i, 0, 0 );
-#else /* !NEW_LOGGING */
-                               Debug( LDAP_DEBUG_ANY, "Unlock CR index = %d\n",
-                                               i, 0, 0 );
-#endif /* !NEW_LOGGING */
-                               ldap_pvt_thread_rdwr_wunlock(&templ->t_rwlock);  
-                               uuid.bv_val = query->q_uuid; 
-                               uuid.bv_len = strlen(query->q_uuid); 
-                               return_val = remove_query_data(op, &rs, &uuid, &result); 
-#ifdef NEW_LOGGING
-                               LDAP_LOG( BACK_META, DETAIL1,
-                                               "STALE QUERY REMOVED, SIZE=%d\n",
-                                               return_val, 0, 0 );
-#else /* !NEW_LOGGING */
-                               Debug( LDAP_DEBUG_ANY, "STALE QUERY REMOVED, SIZE=%d\n",
-                                                       return_val, 0, 0 );
-#endif /* !NEW_LOGGING */
-                               ldap_pvt_thread_mutex_lock(&cm->cache_mutex); 
-                               cm->total_entries -= result.rc; 
-                               cm->num_cached_queries--; 
-#ifdef NEW_LOGGING
-                               LDAP_LOG( BACK_META, DETAIL1, "STORED QUERIES = %lu\n",
-                                               cm->num_cached_queries, 0, 0 );
-#else /* !NEW_LOGGING */
-                               Debug( LDAP_DEBUG_ANY, "STORED QUERIES = %lu\n",
-                                               cm->num_cached_queries, 0, 0 );
-#endif /* !NEW_LOGGING */
-                               ldap_pvt_thread_mutex_unlock(&cm->cache_mutex); 
-                               cm->cache_size = (return_val > cm->cache_size) ?
-                                                       0: (cm->cache_size-return_val);
-#ifdef NEW_LOGGING
-                               LDAP_LOG( BACK_META, DETAIL1,
-                                       "STALE QUERY REMOVED, CACHE SIZE=%lu bytes %d "
-                                       "entries\n", cm->cache_size,
-                                       cm->total_entries, 0 );
-#else /* !NEW_LOGGING */
-                               Debug( LDAP_DEBUG_ANY,
-                                       "STALE QUERY REMOVED, CACHE SIZE=%lu bytes %d "
-                                       "entries\n", cm->cache_size,
-                                       cm->total_entries, 0 );
-#endif /* !NEW_LOGGING */
-                               query_prev = query; 
-                               query = query->prev; 
-                               free_query(query_prev); 
-                       }
-                       ldap_pvt_thread_mutex_unlock(&cm->remove_mutex); 
-               }
-       }
-}
-
-static int
-cache_back_sentry(
-       Operation* op, 
-       SlapReply *rs )
-{ 
-       slap_callback           *cb = op->o_callback; 
-       /*struct metainfo       *li = ( struct metainfo * )op->o_bd->be_private;*/
-       Backend* be = (Backend*)(cb->sc_private);
-       struct metainfo         *li = ( struct metainfo * )be->be_private;
-       char                    *ename = NULL;
-       struct exception        result;
-       struct berval           dn;
-       struct berval           ndn;
-       if (rs->sr_type == REP_SEARCH) {
-               dn = rs->sr_entry->e_name; 
-               ndn = rs->sr_entry->e_nname; 
-
-               rewriteSession( li->rwinfo, "cacheReturn",
-                               rs->sr_entry->e_name.bv_val, op->o_conn,
-                               &ename, &result );  
-               ber_str2bv(ename, strlen(ename), 0, &rs->sr_entry->e_name); 
-               /* FIXME: should we normalize this? */
-               ber_dupbv(&rs->sr_entry->e_nname, &rs->sr_entry->e_name); 
-
-               op->o_callback = NULL; 
-
-               send_search_entry( op, rs );
-        
-               rs->sr_entry->e_name = dn; 
-               rs->sr_entry->e_nname = ndn; 
-
-               op->o_callback = cb; 
-               return LDAP_SUCCESS; 
-
-       } else if (rs->sr_type == REP_RESULT) { 
-               op->o_callback = NULL; 
-               send_ldap_result( op, rs ); 
-               return LDAP_SUCCESS; 
-       }
-
-       return LDAP_SUCCESS;
-}
diff --git a/servers/slapd/back-meta/cache-substring.c b/servers/slapd/back-meta/cache-substring.c
deleted file mode 100644 (file)
index 81e92a3..0000000
+++ /dev/null
@@ -1,290 +0,0 @@
-/* $OpenLDAP$ */
-/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
- *
- * Copyright 1999-2003 The OpenLDAP Foundation.
- * Portions Copyright 2003 IBM Corporation.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted only as authorized by the OpenLDAP
- * Public License.
- *
- * A copy of this license is available in the file LICENSE in the
- * top-level directory of the distribution or, alternatively, at
- * <http://www.OpenLDAP.org/license.html>.
- */
-/* ACKNOWLEDGEMENTS:
- * This work was initially developed by the Apurva Kumar for inclusion
- * in OpenLDAP Software.
- */
-
-#include "portable.h"
-
-#include <stdio.h>
-
-#include <ac/socket.h>
-#include <ac/string.h>
-#include <ac/time.h>
-
-#include "slap.h"
-#include "../back-ldap/back-ldap.h"
-#include "back-meta.h"
-#include "ldap_pvt.h"
-#undef ldap_debug      /* silence a warning in ldap-int.h */
-#include "ldap_log.h"
-#include "../../../libraries/libldap/ldap-int.h"
-
-#include "slap.h"
-#include "back-meta.h"
-
-static char* invert_string(char* string);
-static struct berval* merge_init_final(struct berval*, struct berval*, struct berval*); 
-static int strings_containment(struct berval* stored, struct berval* incoming); 
-
-/* find and remove string2 from string1 
- * from start if position = 1, 
- * from end if position = 3,
- * from anywhere if position = 2
- */
-
-int 
-find_and_remove(struct berval* ber1, struct berval* ber2, int position)
-{
-       char* temp; 
-       int len; 
-       int ret=0;
-
-       char* arg1, *arg2;  
-       char* string1=ber1->bv_val;
-       char* string2=ber2->bv_val;
-       
-       if (string2 == NULL) 
-               return 1; 
-       if (string1 == NULL) 
-               return 0; 
-
-       if (position == 3) {
-               arg1 = invert_string(string1); 
-               arg2 = invert_string(string2); 
-       } else {
-               arg1 = string1; 
-               arg2 = string2; 
-       }
-           
-       temp = strstr(arg1, arg2); 
-       len = strlen(arg2);     
-
-       if (!temp) 
-               return 0; 
-    
-       switch (position) {
-       case 1: 
-               if (temp == arg1) {
-                       string1 += len; 
-                       ret = 1; 
-               } else {
-                       ret = 0; 
-               }
-               break; 
-       case 2: 
-               string1 = temp+len;  
-               ret = 1; 
-               break; 
-       case 3: 
-               temp = strstr(arg1, arg2); 
-               len = strlen(arg2);     
-               if (temp == arg1) {
-                       /*arg1 += len;*/ 
-                       string1 = invert_string(arg1+len); 
-                       free(arg1);             
-                       free(arg2);             
-                       ret = 1; 
-               } else {
-                       free(arg1);             
-                       free(arg2);             
-                       ret = 0; 
-               }
-               break; 
-       }
-       temp = (char*) malloc( strlen( string1 ) + 1 );
-       strcpy( temp, string1 );
-       free( ber1->bv_val );
-       ber1->bv_val = temp;
-       return ret;
-}
-
-char*
-invert_string( char* string )
-{
-       int len = strlen(string); 
-       int i; 
-
-       char* inverted = (char*)(malloc(len+1)); 
-
-       for (i=0; i<len; i++) 
-               inverted[i] = string[len-i-1];
-
-       inverted[len] ='\0'; 
-
-       return inverted; 
-}      
-
-struct berval*  
-merge_init_final(struct berval* init, struct berval* any, struct berval* final)
-{
-       struct berval* merged, *temp; 
-       int i, any_count, count; 
-
-       for (any_count=0; any && any[any_count].bv_val; any_count++)
-               ;
-
-       count = any_count; 
-
-       if (init->bv_val) 
-               count++; 
-       if (final->bv_val)
-               count++; 
-
-       merged = (struct berval*)(malloc((count+1)*sizeof(struct berval))); 
-       temp = merged; 
-
-       if (init->bv_val) {
-               ber_dupbv(temp, init); 
-               temp++;
-       }
-
-       for (i=0; i<any_count; i++) {
-               ber_dupbv(temp, any); 
-               any++;
-               temp++; 
-       } 
-
-       if (final->bv_val){ 
-               ber_dupbv(temp, final);
-               temp++;
-       }        
-       temp->bv_val = NULL; 
-       temp->bv_len = 0; 
-       return merged; 
-}
-
-int
-strings_containment(struct berval* stored, struct berval* incoming)
-{
-       struct berval* element;
-       int k=0;
-       int j, rc = 0; 
-       
-       for ( element=stored; element->bv_val != NULL; element++ ) {
-               for (j = k; incoming[j].bv_val != NULL; j++) {
-                       if (find_and_remove(&(incoming[j]), element, 2)) {
-                               k = j; 
-                               rc = 1; 
-                               break; 
-                       }
-                       rc = 0; 
-               }
-               if ( rc ) {
-                       continue; 
-               } else {
-                       return 0;
-               }
-       }   
-       return 1;
-}
-
-int
-substr_containment_substr(Filter* stored, Filter* incoming) 
-{
-       int i; 
-       int k=0; 
-       int rc; 
-       int any_count = 0; 
-
-       struct berval* init_incoming = (struct berval*)(malloc(sizeof(struct berval))); 
-       struct berval* final_incoming = (struct berval*)(malloc(sizeof(struct berval)));  
-       struct berval* any_incoming = NULL; 
-       struct berval* remaining_incoming; 
-       struct berval* any_element; 
-
-       if ((!(incoming->f_sub_initial.bv_val) && (stored->f_sub_initial.bv_val)) 
-          || (!(incoming->f_sub_final.bv_val) && (stored->f_sub_final.bv_val))) 
-               return 0; 
-       
-       ber_dupbv(init_incoming, &(incoming->f_sub_initial)); 
-       ber_dupbv(final_incoming, &(incoming->f_sub_final)); 
-
-       if (incoming->f_sub_any) { 
-               for ( any_count=0; incoming->f_sub_any[any_count].bv_val != NULL;
-                               any_count++ )
-                       ;
-           
-               any_incoming = (struct berval*)malloc((any_count+1) *
-                                               sizeof(struct berval)); 
-           
-               for (i=0; i<any_count; i++) {
-                       ber_dupbv(&(any_incoming[i]), &(incoming->f_sub_any[i])); 
-               }
-               any_incoming[any_count].bv_val = NULL; 
-               any_incoming[any_count].bv_len = 0; 
-       }
-  
-       if (find_and_remove(init_incoming, 
-                       &(stored->f_sub_initial), 1) && find_and_remove(final_incoming, 
-                       &(stored->f_sub_final), 3)) 
-       {
-               if (stored->f_sub_any == NULL) {
-                       rc = 1; 
-                       goto final; 
-               }
-               remaining_incoming = merge_init_final(init_incoming,
-                                               any_incoming, final_incoming); 
-               rc = strings_containment(stored->f_sub_any, remaining_incoming);
-               goto final; 
-       }       
-       rc = 0; 
-final:
-       /*
-       ber_bvfree(init_incoming);
-       ber_bvfree(final_incoming); 
-       if (any_incoming) {
-               for (i=0; i < any_count; i++) 
-                       free(any_incoming[i].bv_val);
-               free(any_incoming); 
-       }       
-       */
-               
-       return rc; 
-}
-
-int
-substr_containment_equality(Filter* stored, Filter* incoming) 
-{
-               
-       struct berval* incoming_val = (struct berval*)(malloc(2*sizeof(struct berval)));
-       int rc;
-       ber_dupbv(incoming_val, &(incoming->f_av_value));
-       incoming_val[1].bv_val = NULL;
-       incoming_val[1].bv_len = 0;
-       if (find_and_remove(incoming_val, 
-                       &(stored->f_sub_initial), 1) && find_and_remove(incoming_val, 
-                       &(stored->f_sub_final), 3)) {
-               if (stored->f_sub_any == NULL){ 
-                       rc = 1;
-                       goto final;
-               }       
-               rc = strings_containment(stored->f_sub_any, incoming_val);
-               goto final;
-       }
-       rc=0;
-final:
-       /*
-       if(incoming_val[0].bv_val)
-               free(incoming_val[0].bv_val);
-       free(incoming_val); 
-       */
-       return rc;
-}              
diff --git a/servers/slapd/back-meta/cache-template.c b/servers/slapd/back-meta/cache-template.c
deleted file mode 100644 (file)
index 21e557e..0000000
+++ /dev/null
@@ -1,247 +0,0 @@
-/* $OpenLDAP$ */
-/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
- *
- * Copyright 1999-2003 The OpenLDAP Foundation.
- * Portions Copyright 2003 IBM Corporation.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted only as authorized by the OpenLDAP
- * Public License.
- *
- * A copy of this license is available in the file LICENSE in the
- * top-level directory of the distribution or, alternatively, at
- * <http://www.OpenLDAP.org/license.html>.
- */
-/* ACKNOWLEDGEMENTS:
- * This work was initially developed by the Apurva Kumar for inclusion
- * in OpenLDAP Software based, in part, on existing OpenLDAP Software.
- */
-
-#include "portable.h"
-
-#include <stdio.h>
-
-#include <ac/socket.h>
-#include <ac/string.h>
-#include <ac/time.h>
-
-#include "slap.h"
-#include "../back-ldap/back-ldap.h"
-#include "back-meta.h"
-#undef ldap_debug      /* silence a warning in ldap-int.h */
-#include "../../../libraries/libldap/ldap-int.h"
-
-void 
-filter2template(
-       Filter                  *f,
-       struct                  berval *fstr,
-       AttributeName**         filter_attrs, 
-       int*                    filter_cnt,
-       struct exception*       result  )
-{
-       int     i;
-       Filter  *p;
-       struct berval tmp;
-       ber_len_t len;
-       const char* text; 
-
-       /*
-        * FIXME: should we use an assert here?
-        */
-       if ( f == NULL ) {
-               ber_str2bv( "No filter!", sizeof("No filter!")-1, 1, fstr );
-               result->type = FILTER_ERR; 
-               return; 
-       }
-
-       switch ( f->f_choice ) {
-       case LDAP_FILTER_EQUALITY:
-               fstr->bv_len = f->f_av_desc->ad_cname.bv_len +
-                               ( sizeof("(=)") - 1 );
-               fstr->bv_val = ch_malloc( fstr->bv_len + 1 );
-
-               snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s=)",
-                               f->f_av_desc->ad_cname.bv_val );
-
-               *filter_attrs = (AttributeName *)ch_realloc(*filter_attrs,
-                               (*filter_cnt + 2)*sizeof(AttributeName)); 
-               
-#if 0  /* ? */
-               ber_dupbv(&(*filter_attrs)[*filter_cnt].an_name,
-                               &f->f_av_desc->ad_cname); 
-#endif
-               
-               (*filter_attrs)[*filter_cnt].an_name = f->f_av_desc->ad_cname; 
-               (*filter_attrs)[*filter_cnt].an_desc = NULL; 
-               slap_bv2ad(&f->f_av_desc->ad_cname,
-                               &(*filter_attrs)[*filter_cnt].an_desc, &text); 
-               (*filter_attrs)[*filter_cnt+1].an_name.bv_val = NULL; 
-               (*filter_attrs)[*filter_cnt+1].an_name.bv_len = 0; 
-               (*filter_cnt)++; 
-               break;
-       case LDAP_FILTER_GE:
-               fstr->bv_len = f->f_av_desc->ad_cname.bv_len +
-                               + ( sizeof("(>=)") - 1 );
-               fstr->bv_val = ch_malloc( fstr->bv_len + 1 );
-
-               snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s>=)",
-                       f->f_av_desc->ad_cname.bv_val);
-
-               *filter_attrs = (AttributeName *)ch_realloc(*filter_attrs, 
-                               (*filter_cnt + 2)*sizeof(AttributeName)); 
-#if 0  /* ? */
-               ber_dupbv(&(*filter_attrs)[filter_cnt].an_name,
-                               &f->f_av_desc->ad_cname);
-#endif
-
-               (*filter_attrs)[*filter_cnt].an_name = f->f_av_desc->ad_cname; 
-               (*filter_attrs)[*filter_cnt].an_desc = NULL; 
-               slap_bv2ad(&f->f_av_desc->ad_cname,
-                               &(*filter_attrs)[*filter_cnt].an_desc, &text); 
-               (*filter_attrs)[*filter_cnt+1].an_name.bv_val = NULL; 
-               (*filter_attrs)[*filter_cnt+1].an_name.bv_len = 0; 
-               (*filter_cnt)++; 
-
-               break;
-
-       case LDAP_FILTER_LE:
-               fstr->bv_len = f->f_av_desc->ad_cname.bv_len +
-                       + ( sizeof("(<=)") - 1 );
-               fstr->bv_val = ch_malloc( fstr->bv_len + 1 );
-
-               snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s<=)",
-                       f->f_av_desc->ad_cname.bv_val);
-
-               *filter_attrs = (AttributeName *)ch_realloc(*filter_attrs, 
-                               (*filter_cnt + 2)*sizeof(AttributeName)); 
-#if 0  /* ? */
-               ber_dupbv(&(*filter_attrs)[filter_cnt].an_name,
-                               &f->f_av_desc->ad_cname);
-#endif
-               
-               (*filter_attrs)[*filter_cnt].an_name = f->f_av_desc->ad_cname; 
-               (*filter_attrs)[*filter_cnt].an_desc = NULL; 
-               slap_bv2ad(&f->f_av_desc->ad_cname,
-                               &(*filter_attrs)[*filter_cnt].an_desc, &text); 
-               (*filter_attrs)[*filter_cnt+1].an_name.bv_val = NULL; 
-               (*filter_attrs)[*filter_cnt+1].an_name.bv_len = 0; 
-               (*filter_cnt++); 
-
-               break;
-
-       case LDAP_FILTER_APPROX:
-               fstr->bv_len = f->f_av_desc->ad_cname.bv_len +
-                       + ( sizeof("(~=)") - 1 );
-               fstr->bv_val = ch_malloc( fstr->bv_len + 1 );
-
-               snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s~=)",
-                       f->f_av_desc->ad_cname.bv_val);
-               
-               *filter_attrs = (AttributeName *)ch_realloc(*filter_attrs,
-                               (*filter_cnt + 2)*sizeof(AttributeName));
-
-#if 0  /* ? */
-               ber_dupbv(&(*filter_attrs)[filter_cnt].an_name,
-                               &f->f_av_desc->ad_cname);
-#endif
-               
-               (*filter_attrs)[*filter_cnt].an_name = f->f_av_desc->ad_cname; 
-               (*filter_attrs)[*filter_cnt].an_desc = NULL; 
-               slap_bv2ad(&f->f_av_desc->ad_cname,
-                               &(*filter_attrs)[*filter_cnt].an_desc, &text); 
-               (*filter_attrs)[*filter_cnt+1].an_name.bv_val = NULL; 
-               (*filter_attrs)[*filter_cnt+1].an_name.bv_len = 0; 
-               (*filter_cnt)++; 
-
-               break;
-
-       case LDAP_FILTER_SUBSTRINGS:
-               fstr->bv_len = f->f_sub_desc->ad_cname.bv_len +
-                       ( sizeof("(=)") - 1 );
-               fstr->bv_val = ch_malloc( fstr->bv_len + 1 );
-
-               snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s=)",
-                       f->f_sub_desc->ad_cname.bv_val );
-
-               *filter_attrs = (AttributeName *)ch_realloc(*filter_attrs,
-                               (*filter_cnt + 2)*sizeof(AttributeName));
-
-#if 0  /* ? */
-               ber_dupbv(&(*filter_attrs)[filter_cnt].an_name,
-                               &f->f_av_desc->ad_cname);
-#endif
-               
-               (*filter_attrs)[*filter_cnt].an_name = f->f_av_desc->ad_cname; 
-               (*filter_attrs)[*filter_cnt].an_desc = NULL; 
-               slap_bv2ad(&f->f_av_desc->ad_cname,
-                               &(*filter_attrs)[*filter_cnt].an_desc, &text);
-               (*filter_attrs)[*filter_cnt+1].an_name.bv_val = NULL; 
-               (*filter_attrs)[*filter_cnt+1].an_name.bv_len = 0; 
-               (*filter_cnt)++; 
-
-               break;
-
-       case LDAP_FILTER_PRESENT:
-               fstr->bv_len = f->f_desc->ad_cname.bv_len +
-                       ( sizeof("(=*)") - 1 );
-               fstr->bv_val = ch_malloc( fstr->bv_len + 1 );
-
-               snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s=*)",
-                       f->f_desc->ad_cname.bv_val );
-
-               *filter_attrs = (AttributeName *)ch_realloc(*filter_attrs,
-                               (*filter_cnt+2)*sizeof(AttributeName)); 
-
-#if 0  /* ? */
-               ber_dupbv(&(*filter_attrs)[filter_cnt].an_name,
-                               &f->f_av_desc->ad_cname);
-#endif
-               
-               (*filter_attrs)[*filter_cnt].an_name = f->f_desc->ad_cname; 
-               (*filter_attrs)[*filter_cnt].an_desc = NULL; 
-               slap_bv2ad(&f->f_desc->ad_cname,
-                               &(*filter_attrs)[*filter_cnt].an_desc, &text);
-               (*filter_attrs)[*filter_cnt+1].an_name.bv_val = NULL; 
-               (*filter_attrs)[*filter_cnt+1].an_name.bv_len = 0; 
-               (*filter_cnt)++; 
-
-               break;
-
-       case LDAP_FILTER_AND:
-       case LDAP_FILTER_OR:
-       case LDAP_FILTER_NOT:
-               fstr->bv_len = sizeof("(%)") - 1;
-               fstr->bv_val = ch_malloc( fstr->bv_len + 128 );
-
-               snprintf( fstr->bv_val, fstr->bv_len + 1, "(%c)",
-                       f->f_choice == LDAP_FILTER_AND ? '&' :
-                       f->f_choice == LDAP_FILTER_OR ? '|' : '!' );
-
-               for ( p = f->f_list; p != NULL; p = p->f_next ) {
-                       len = fstr->bv_len;
-
-                       filter2template( p, &tmp, filter_attrs, filter_cnt,
-                                       result); 
-                       if (result->type != SUCCESS) {
-                               return; 
-                       }
-                       
-                       fstr->bv_len += tmp.bv_len;
-                       fstr->bv_val = ch_realloc( fstr->bv_val,
-                                       fstr->bv_len + 1 );
-
-                       snprintf( &fstr->bv_val[len-1], tmp.bv_len + 2, 
-                               /*"("*/ "%s)", tmp.bv_val );
-
-                       ch_free( tmp.bv_val );
-               }
-
-               break;
-
-       default:
-               ber_str2bv( "(?=unknown)", sizeof("(?=unknown)")-1, 1, fstr );
-               result->type = FILTER_ERR; 
-               return;
-       }
-}
diff --git a/servers/slapd/back-meta/cache.h b/servers/slapd/back-meta/cache.h
deleted file mode 100644 (file)
index 6a7525f..0000000
+++ /dev/null
@@ -1,210 +0,0 @@
-/* $OpenLDAP$ */
-/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
- *
- * Copyright 1999-2003 The OpenLDAP Foundation.
- * Portions Copyright 2003 IBM Corporation.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted only as authorized by the OpenLDAP
- * Public License.
- *
- * A copy of this license is available in the file LICENSE in the
- * top-level directory of the distribution or, alternatively, at
- * <http://www.OpenLDAP.org/license.html>.
- */
-/* ACKNOWLEDGEMENTS:
- * This work was initially developed by the Apurva Kumar for inclusion
- * in OpenLDAP Software.
- */
-
-#ifndef META_CACHE_H
-#define META_CACHE_H
-#include "slap.h"
-
-/* cache specific errors */
-enum type_of_result { 
-    SUCCESS, 
-    CONN_ERR, 
-    RESULT_ERR, 
-    FILTER_ERR, 
-    REWRITING_ERR,
-    MERGE_ERR, 
-    REMOVE_ERR, 
-    SLIMIT_ERR, 
-    ABANDON_ERR, 
-    CREATE_ENTRY_ERR, 
-    TIMEOUT_ERR, 
-    SIZE_ERR, 
-    GET_SIZE_ERR
-};   
-
-
-struct exception {
-    enum type_of_result type; 
-    int  rc; 
-};
-
-/* query cache structs */
-/* query */
-
-typedef struct Query_s {
-       Filter*         filter;         /* Search Filter */
-       AttributeName*  attrs;          /* Projected attributes */
-       struct berval   base;           /* Search Base */
-       int             scope;          /* Search scope */
-} Query;
-
-/* struct representing a cached query */
-typedef struct cached_query_s {
-       Query                           query;          /* LDAP query */ 
-       char*                           q_uuid;         /* query identifier */ 
-       int                             template_id;    /* template of the query */ 
-       time_t                          expiry_time;    /* time till the query is considered valid */ 
-       struct cached_query_s           *next;          /* next query in the template */
-       struct cached_query_s           *prev;          /* previous query in the template */
-       struct cached_query_s           *lru_up;        /* previous query in the LRU list */ 
-       struct cached_query_s           *lru_down;      /* next query in the LRU list */ 
-} CachedQuery; 
-
-/* struct representing a query template
- * e.g. template string = &(cn=)(mail=) 
- */
-typedef struct query_template_s {
-       char*           querystr;       /* Filter string corresponding to the QT */
-       char*           base;           /* Search base */ 
-       int             attr_set_index; /* determines the projected attributes */ 
-
-       CachedQuery*    query;          /* most recent query cached for the template */ 
-       CachedQuery*    query_last;     /* oldest query cached for the template */              
-
-       int             no_of_queries;  /* Total number of queries in the template */
-       long            ttl;            /* TTL for the queries of this template */ 
-        ldap_pvt_thread_rdwr_t t_rwlock; /* Rd/wr lock for accessing queries in the template */ 
-} QueryTemplate;
-
-/* 
- * Represents a set of projected attributes and any
- * supersets among all specified sets of attributes. 
- */
-
-struct attr_set {
-       AttributeName*  attrs;          /* specifies the set */
-       int             count;          /* number of attributes */ 
-       int*            ID_array;       /* array of indices of supersets of 'attrs' */ 
-};
-
-struct query_manager_s; 
-
-/* prototypes for functions for 1) query containment 
- * 2) query addition, 3) cache replacement 
- */
-typedef int    (*QCfunc)(struct query_manager_s*, Query*, int );
-typedef void   (*AddQueryfunc)(struct query_manager_s*, Query*, int, char*, struct exception* );
-typedef char*          (*CRfunc)(struct query_manager_s* );
-
-/* LDAP query cache */ 
-typedef struct query_manager_s {
-       struct attr_set*        attr_sets;              /* possible sets of projected attributes */
-       QueryTemplate*          templates;              /* cacheable templates */
-
-       CachedQuery*            lru_top;                /* top and bottom of LRU list */
-       CachedQuery*            lru_bottom;
-
-       ldap_pvt_thread_mutex_t         lru_mutex;      /* mutex for accessing LRU list */
-
-       /* Query cache methods */
-       QCfunc                  qcfunc;                 /* Query containment*/  
-       CRfunc                  crfunc;                 /* cache replacement */
-       AddQueryfunc            addfunc;                /* add query */ 
-} query_manager; 
-
-/* LDAP query cache manager */ 
-typedef struct cache_manager_s {
-       unsigned long   cache_size;                     /* current cache size (bytes) */ 
-       unsigned long   thresh_hi;                      /* cache capacity (bytes) */
-       unsigned long   thresh_lo;                      /* lower threshold for cache replacement */
-       unsigned long   num_cached_queries;             /* total number of cached queries */
-       unsigned long   max_queries;                    /* upper bound on # of cached queries */ 
-       int     caching; 
-
-       int     numattrsets;                    /* number of attribute sets */
-       int     numtemplates;                   /* number of cacheable templates */
-       int     total_entries;                  /* total number of entries cached */ 
-        int     num_entries_limit;             /* max # of entries in a cacheable query */ 
-       int     threads;                        /* number of threads currently in meta_back_search */ 
-
-       int     cc_period;              /* interval between successive consistency checks (sec) */ 
-       int     cc_thread_started; 
-       ldap_pvt_thread_t   cc_thread; 
-
-       ldap_pvt_thread_mutex_t         cache_mutex;            
-       ldap_pvt_thread_mutex_t         remove_mutex;
-       ldap_pvt_thread_mutex_t         cc_mutex;       
-
-       query_manager*   qm;    /* query cache managed by the cache manager */ 
-} cache_manager; 
-
-/* search-cache.c */
-int
-meta_back_cache_search(
-    Operation          *op,
-    SlapReply          *rs
-); 
-
-/* config-cache.c */
-int
-meta_back_cache_config(
-       BackendDB       *be,
-       const char      *fname,
-       int             lineno,
-       int             argc,
-       char            **argv
-); 
-
-/* query-cache.c */
-int    query_containment(query_manager*, Query*, int); 
-void   add_query(query_manager*, Query*, int, char*, struct exception*);
-char*  cache_replacement(query_manager*);
-void   remove_from_template (CachedQuery*, QueryTemplate*); 
-void   remove_query (query_manager*, CachedQuery*);
-void   free_query (CachedQuery*); 
-
-/* substring.c */
-int    substr_containment_substr(Filter*, Filter*); 
-int    substr_containment_equality(Filter*, Filter*); 
-
-/* template.c */
-void 
-filter2template( Filter *f, 
-                struct berval *fstr, 
-                AttributeName** filter_attrs, 
-                int* filter_cnt, 
-                struct exception* result
-);
-
-/* merge.c */
-
-int
-merge_entry (
-           Operation           *op, 
-           SlapReply           *rs,
-           struct berval       *query_uuid, 
-           struct exception    *result
-); 
-
-int 
-get_entry_size(Entry* e, 
-              int size_init, 
-              struct exception* result
-); 
-
-/* remove.c */
-int 
-remove_query_data (
-                  Operation* conn,
-                  SlapReply *rs,
-                  struct berval* query_uuid, 
-                  struct exception* result
-);
-#endif
index 9ef426f848ff9a3172aa35b27f5d7d5defd42aac..97729874278f022a255f092885d132314461cb10 100644 (file)
@@ -565,10 +565,6 @@ meta_back_db_config(
                                fname, lineno, argc, argv );
        /* anything else */
        } else {
-               if ( meta_back_cache_config( be, fname, lineno, argc, argv ) == 0 ) {
-                       return 0;
-               }
-
                fprintf( stderr,
        "%s: line %d: unknown directive \"%s\" in meta database definition"
        " (ignored)\n",
index 293ddcf265ab9875fce83421c50bea401c41fcdc..c983d8164d3006184c63b1bcacf27572080909d7 100644 (file)
@@ -154,69 +154,24 @@ meta_back_db_init(
        struct metainfo *li;
 
        struct rewrite_info     *rwinfo;
-       cache_manager           *cm;
-       query_manager           *qm;
 
        rwinfo = rewrite_info_init( REWRITE_MODE_USE_DEFAULT );
        if ( rwinfo == NULL ) {
                return -1;
        }
-               
-       cm = (cache_manager *)ch_malloc(sizeof(cache_manager)); 
-       if ( cm == NULL ) {
-               rewrite_info_delete( &rwinfo );
-               return -1;
-       }
-
-       qm = (query_manager*)ch_malloc(sizeof(query_manager)); 
-       if ( qm == NULL ) {
-               rewrite_info_delete( &rwinfo );
-               ch_free( cm );
-               return -1;
-       }
-
-       cm->caching = 0; 
-       cm->qm = qm; 
-       cm->numattrsets = 0; 
-       cm->numtemplates = 0;   
-       cm->num_entries_limit = 5;
-       cm->cache_size = 0;
-       cm->thresh_hi = 500000;
-       cm->thresh_lo = 700000;
-       cm->num_cached_queries = 0; 
-       cm->total_entries = 0; 
-       cm->max_queries = 10000; 
-       cm->threads = 0; 
-       cm->cc_thread_started = 0; 
-       cm->cc_period = 1000; 
-       
-       qm->attr_sets = NULL; 
-       qm->templates = NULL; 
-       qm->lru_top = NULL;
-       qm->lru_bottom = NULL;
-
-       qm->qcfunc = query_containment; 
-       qm->crfunc = cache_replacement; 
-       qm->addfunc = add_query; 
-       ldap_pvt_thread_mutex_init(&qm->lru_mutex); 
-        
-       ldap_pvt_thread_mutex_init(&cm->cache_mutex); 
-       ldap_pvt_thread_mutex_init(&cm->remove_mutex); 
-       ldap_pvt_thread_mutex_init( &cm->cc_mutex );
 
        li = ch_calloc( 1, sizeof( struct metainfo ) );
        if ( li == NULL ) {
+               rewrite_info_delete( &rwinfo );
                return -1;
        }
-       
+
        /*
         * At present the default is no default target;
         * this may change
         */
        li->defaulttarget = META_DEFAULT_TARGET_NONE;
-       li->cm = cm; 
        li->rwinfo = rwinfo;
-       /* FIXME: what about qm ? */
 
        ldap_pvt_thread_mutex_init( &li->conn_mutex );
        ldap_pvt_thread_mutex_init( &li->cache.mutex );
index 2fe1b3bad5ac93d6ea30f1b10450fac7e669ca25..e3ebf67529c3c9f2eec13aed399180e0b283756f 100644 (file)
@@ -131,12 +131,6 @@ meta_back_search( Operation *op, SlapReply *rs )
        int isroot = 0;
        dncookie dc;
 
-       cache_manager*  cm = li->cm;
-
-       if (cm->caching) {
-               return meta_back_cache_search(op, rs);
-       }
-       
        /*
         * controls are set in ldap_back_dobind()
         *