]> git.sur5r.net Git - openldap/commitdiff
now LDAP_CACHING can be enabled again; not sure it works, though
authorPierangelo Masarati <ando@openldap.org>
Fri, 9 May 2003 00:36:31 +0000 (00:36 +0000)
committerPierangelo Masarati <ando@openldap.org>
Fri, 9 May 2003 00:36:31 +0000 (00:36 +0000)
servers/slapd/back-meta/cache-merge.c
servers/slapd/back-meta/cache-query.c
servers/slapd/back-meta/cache-remove.c
servers/slapd/back-meta/cache-search.c
servers/slapd/back-meta/cache.h
servers/slapd/back-meta/search.c

index 8c453e11d629563d95d409121004b01c70b658d0..57b75d93edc4841a77b4e94b99fa7064962c2d5e 100644 (file)
 #include <sys/time.h>
 
 #ifdef LDAP_CACHING
+
+static struct berval bv_queryid_any = BER_BVC( "(queryid=*)" );
+
 static int
 merge_func (
-       Backend *be,
-       Connection      *conn,
        Operation       *op,
-       Entry   *stored_entry,
-       AttributeName   *attrs,
-       int             attrsonly,
-       LDAPControl **ctrls
+       SlapReply       *rs
 ); 
 
 void
 add_func (
-       Connection      *conn,
        Operation       *op,
-       ber_int_t       err,
-       const char      *matched,
-       const char      *text,
-       BerVarray       refs,
-       LDAPControl     **ctrls,
-       int             nentries
+       SlapReply       *rs
 ); 
 
 static Attribute* 
-add_attribute(const char* attr_name, 
+add_attribute(AttributeDescription *ad,
        Entry* e,
        BerVarray value_array
 ); 
 
 static int
 get_size_func (
-       Backend         *be,
-       Connection      *conn,
        Operation       *op,
-       Entry           *entry,
-       AttributeName   *attrs,
-       int             attrsonly,
-       LDAPControl     **ctrls
+       SlapReply       *rs
 ); 
 
-
-/* Two empty callback functions to avoid sending results */
-void callback_null_response(
-       Connection      *conn,
-       Operation       *o,
-       ber_tag_t       tag,
-       ber_int_t       msgid,
-       ber_int_t       err,
-       const char      *matched,
-       const char      *text,
-       BerVarray       ref,
-       const char      *resoid,
-       struct berval   *resdata,
-       struct berval   *sasldata,
-       LDAPControl     **c     )
-{
-}
-
-void callback_null_sresult(
-       Connection      *conn,
-       Operation       *o,
-       ber_int_t       err,
-       const char      *matched,
-       const char      *text,
-       BerVarray       refs,
-       LDAPControl     **c,
-       int nentries    )
-{
-}
-
 struct entry_info {
        int                     size_init; 
        int                     size_final; 
@@ -149,51 +106,74 @@ get_entry_size(
        return size;
 }
 
+/* quick hack: call the right callback */
+static int
+add_merge_func( Operation *op, SlapReply *rs )
+{
+       switch ( rs->sr_type ) {
+       case REP_SEARCH:
+               add_func( op, rs );
+               break;
+
+       case REP_RESULT:
+               merge_func( op, rs );
+               break;
+       }
+       return 0;
+}
 
 int
-merge_entry (
-       Backend*                be,
-       Connection*             conn, 
-       Entry*                  e, 
+merge_entry(
+       Operation               *op,
+       SlapReply               *rs,
        struct berval*          query_uuid, 
-       struct exception*       result  )
+       struct exception*       result )
 {
-       struct entry_info info; 
-       struct berval normdn; 
-       struct berval prettydn; 
-
-       Operation op = {0};
-       slap_callback cb = {callback_null_response, 
-               add_func, merge_func, NULL}; 
-
-       Filter* filter = str2filter("(queryid=*)");           
-
-       dnPrettyNormal(0, &(e->e_name), &prettydn, &normdn); 
-
-       free(e->e_name.bv_val); 
-       e->e_name = prettydn; 
-       e->e_nname = normdn; 
-
-       info.entry = e; 
-       info.uuid = query_uuid; 
-       info.size_init = 0; 
-       info.size_final = 0; 
-       info.added = 0; 
-       info.glue_be = be; 
-       info.err = SUCCESS; 
+       struct entry_info info;
+       struct berval normdn;
+       struct berval prettydn;
+
+       Operation op_tmp = *op;
+       slap_callback cb = { add_merge_func, NULL };
+
+       Filter* filter = str2filter( bv_queryid_any.bv_val );
+
+       dnPrettyNormal(0, &rs->sr_entry->e_name, &prettydn, &normdn,
+                       op->o_tmpmemctx);
+
+       free(rs->sr_entry->e_name.bv_val);
+       rs->sr_entry->e_name = prettydn;
+       if (rs->sr_entry->e_nname.bv_val) free(rs->sr_entry->e_nname.bv_val);
+       rs->sr_entry->e_nname = normdn;
+
+       info.entry = rs->sr_entry;
+       info.uuid = query_uuid;
+       info.size_init = 0;
+       info.size_final = 0;
+       info.added = 0;
+       info.glue_be = op->o_bd;
+       info.err = SUCCESS;
        cb.sc_private = &info;
 
-       op.o_tag = LDAP_REQ_SEARCH;
-       op.o_protocol = LDAP_VERSION3;
-       op.o_ndn = conn->c_ndn;
-       op.o_callback = &cb;
-       op.o_caching_on = 1;
-       op.o_time = slap_get_time();
-       op.o_do_not_cache = 1;
-
-       be->be_search( be, conn, &op, NULL, &(e->e_nname),
-               LDAP_SCOPE_BASE, LDAP_DEREF_NEVER, 1, 0,
-               filter, NULL, NULL, 0 );
+       op_tmp.o_tag = LDAP_REQ_SEARCH;
+       op_tmp.o_protocol = LDAP_VERSION3;
+       op_tmp.o_callback = &cb;
+       op_tmp.o_caching_on = 1;
+       op_tmp.o_time = slap_get_time();
+       op_tmp.o_do_not_cache = 1;
+
+       op_tmp.o_req_dn = rs->sr_entry->e_name;
+       op_tmp.o_req_ndn = rs->sr_entry->e_nname;
+       op_tmp.ors_scope = LDAP_SCOPE_BASE;
+       op_tmp.ors_deref = LDAP_DEREF_NEVER;
+       op_tmp.ors_slimit = 1;
+       op_tmp.ors_tlimit = 0;
+       op_tmp.ors_filter = filter;
+       op_tmp.ors_filterstr = bv_queryid_any;
+       op_tmp.ors_attrs = NULL;
+       op_tmp.ors_attrsonly = 0;
+
+       op->o_bd->be_search( &op_tmp, rs );
        result->type = info.err; 
        if ( result->type == SUCCESS )
                result->rc = info.added; 
@@ -204,49 +184,44 @@ merge_entry (
 
 static int
 merge_func (
-       Backend         *be_glue,
-       Connection      *conn,
        Operation       *op,
-       Entry           *e,
-       AttributeName   *attrs,
-       int             attrsonly,
-       LDAPControl     **ctrls
+       SlapReply       *rs
 )
-{ 
-       Backend* be; 
-       char            *new_attr_name;
+{
+       Backend                 *be;
+       char                    *new_attr_name;
        Attribute               *a_new, *a;
-       int             i=0;
-       int             rc=0;
+       int                     i = 0;
+       int                     rc = 0;
     
-       int             count; 
-       struct timeval      time;       /* time */ 
-       long            timediff; /* time */ 
-       slap_callback   *tmp = op->o_callback;  
-       struct entry_info*      info = tmp->sc_private; 
-       Filter* filter = str2filter("(queryid=*)");           
-       Entry* entry = info->entry; 
-       struct berval* uuid = info->uuid; 
-       Modifications *modhead = NULL; 
-       Modifications *mod; 
-       Modifications **modtail = &modhead; 
-       AttributeDescription* a_new_desc;
-       const char      *text = NULL; 
+       int                     count;
+       struct timeval          time;   /* time */
+       long                    timediff; /* time */
+       struct entry_info       *info = op->o_callback->sc_private;
+       Filter                  *filter = str2filter( bv_queryid_any.bv_val );
+       Entry                   *entry = info->entry;
+       struct berval           *uuid = info->uuid;
+       Modifications           *modhead = NULL;
+       Modifications           *mod;
+       Modifications           **modtail = &modhead;
+       AttributeDescription    *a_new_desc;
+       const char              *text = NULL;
+       Operation               op_tmp = *op;
 
        info->err = SUCCESS; 
 
        be = select_backend(&entry->e_nname, 0, 0); 
      
-       info->size_init = get_entry_size(e, 0, 0);  
+       info->size_init = get_entry_size(rs->sr_entry, 0, 0);  
        a_new = entry->e_attrs;
 
        while (a_new != NULL) {
                a_new_desc = a_new->a_desc; 
                mod = (Modifications *) malloc( sizeof(Modifications) );
                mod->sml_op = LDAP_MOD_REPLACE;
-               ber_dupbv(&(mod->sml_type), &(a_new_desc->ad_cname)); 
+               ber_dupbv(&mod->sml_type, &a_new_desc->ad_cname); 
 
-               for (count=0; a_new->a_vals[count].bv_val; count++) 
+               for (count = 0; a_new->a_vals[count].bv_val; count++) 
                        ;
                mod->sml_bvalues = (struct berval*) malloc(
                                (count+1) * sizeof( struct berval) );
@@ -270,7 +245,7 @@ merge_func (
        mod = (Modifications *) ch_malloc( sizeof(Modifications) );
        mod->sml_op = LDAP_MOD_ADD;
        mod->sml_desc = slap_schema.si_ad_queryid; 
-       ber_dupbv(&(mod->sml_type), &(mod->sml_desc->ad_cname)); 
+       ber_dupbv(&mod->sml_type, &mod->sml_desc->ad_cname); 
        mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
        ber_dupbv( mod->sml_bvalues, uuid );
        mod->sml_bvalues[1].bv_val = NULL;
@@ -278,51 +253,60 @@ merge_func (
        *modtail = mod;
        mod->sml_next = NULL; 
 
-       if (be->be_modify(be, conn, op, &(entry->e_name),
-                               &(entry->e_nname), modhead) != 0 ) {
+       /* Apply changes */
+       op_tmp.o_req_dn = entry->e_name;
+       op_tmp.o_req_ndn = entry->e_nname;
+       op_tmp.orm_modlist = modhead;
+
+       if (be->be_modify(op, rs ) != 0 ) {
+               /* FIXME: cleanup ? */
                info->err = MERGE_ERR;
                return 0; 
        }
-       op->o_callback->sc_sendentry = get_size_func; 
-       op->o_callback->sc_sresult = NULL; 
+
+       /* compute the size of the entry */
+       op_tmp.o_callback->sc_response = get_size_func; 
+
+       op_tmp.ors_scope = LDAP_SCOPE_BASE;
+       op_tmp.ors_deref = LDAP_DEREF_NEVER;
+       op_tmp.ors_slimit = 1;
+       op_tmp.ors_tlimit = 0;
+       op_tmp.ors_filter = filter;
+       op_tmp.ors_filterstr = bv_queryid_any;
+       op_tmp.ors_attrs = NULL;
+       op_tmp.ors_attrsonly = 0;
     
-       if (be->be_search( be, conn, op, NULL, &(entry->e_nname),
-                       LDAP_SCOPE_BASE, LDAP_DEREF_NEVER, 1, 0,
-                       filter, NULL, NULL, 0 ) != 0) {
+       if (be->be_search( &op_tmp, rs ) != 0) {
                info->err = GET_SIZE_ERR;
        }
+
        return 0; 
 }
 
 void
 add_func (
-       Connection      *conn,
        Operation       *op,
-       ber_int_t       err,
-       const char      *matched,
-       const char      *text,
-       BerVarray       refs,
-       LDAPControl **ctrls,
-       int             nentries
+       SlapReply       *rs
 )
 {
-       slap_callback   *tmp = op->o_callback;  
-       struct entry_info   *info = tmp->sc_private; 
-       Entry* entry = info->entry; 
-       struct berval* uuid = info->uuid; 
-       Backend* be; 
+       struct entry_info       *info = op->o_callback->sc_private; 
+       Entry                   *entry = info->entry; 
+       struct berval           *uuid = info->uuid; 
+       Backend                 *be; 
        BerVarray               value_array; 
-       Entry           *e; 
+       Entry                   *e; 
        Attribute               *a; 
 
-       struct timeval      time;       /* time */ 
-       long            timediff; /* time */ 
+       struct timeval          time;   /* time */ 
+       long                    timediff; /* time */ 
+
+       Operation               op_tmp = *op;
 
        /* 
         * new entry, construct an entry with 
         * the projected attributes 
         */
-       if (nentries) 
+       if (rs->sr_nentries) 
                return; 
        
        be = select_backend(&entry->e_nname, 0, 0); 
@@ -341,16 +325,21 @@ add_func (
        value_array[1].bv_val = NULL;
        value_array[1].bv_len = 0;
 
-       a = add_attribute("queryid", e, value_array); 
+       a = add_attribute(slap_schema.si_ad_queryid, 
+                       e, value_array); 
 
        /* append the attribute list from the fetched entry */
        a->a_next = entry->e_attrs;
        entry->e_attrs = NULL;
 
        info->size_final = get_entry_size(e, 0, NULL); 
-       if ( be->be_add( be, conn, op, e ) == 0 ) {
+
+       op_tmp.o_bd = be;
+       op_tmp.ora_e = e;
+       
+       if ( be->be_add( &op_tmp, rs ) == 0 ) {
                info->added = 1; 
-               be_entry_release_w( be, conn, op, e );
+               be_entry_release_w( &op_tmp, e );
        } else {
                info->err = MERGE_ERR; 
        }
@@ -358,7 +347,7 @@ add_func (
  
 
 static Attribute* 
-add_attribute(const char* attr_name, 
+add_attribute(AttributeDescription *ad,
        Entry* e, 
        BerVarray value_array) 
 {
@@ -381,28 +370,27 @@ add_attribute(const char* attr_name,
        new_attr->a_next = NULL; 
        new_attr->a_desc = NULL;
        new_attr->a_vals = value_array; 
-       slap_str2ad(attr_name, &(new_attr->a_desc), &text);   
+       new_attr->a_desc = ad;
 
        return new_attr; 
 }
 
 static int
 get_size_func (
-       Backend         *be,
-       Connection      *conn,
        Operation       *op,
-       Entry           *entry,
-       AttributeName   *attrs,
-       int             attrsonly,
-       LDAPControl     **ctrls
+       SlapReply       *rs
 )
 {
-       slap_callback           *tmp = op->o_callback;  
-       struct entry_info       *info = tmp->sc_private; 
+       struct entry_info       *info = op->o_callback->sc_private; 
        struct exception        result; 
 
-       result.type = info->err;  
-       info->size_final = get_entry_size(entry, info->size_init, &result); 
+       if ( rs->sr_type == REP_SEARCH ) {
+               result.type = info->err;  
+               info->size_final = get_entry_size(rs->sr_entry,
+                               info->size_init, &result); 
+       }
+
        return 0; 
-}  
+}
+
 #endif /* LDAP_CACHING */
index 248b516493d9885ea2acecc046939371d1701b3a..58e986dbe232604fe1c2d5ed996881e69aa7bafb 100644 (file)
@@ -273,8 +273,8 @@ int base_scope_compare(
        if (scope_stored < scope_incoming)
                return 0;
 
-       dnNormalize(0, NULL, NULL, dn_incoming, &ndn_incoming);
-       dnNormalize(0, NULL, NULL, dn_stored, &ndn_stored);
+       dnNormalize(0, NULL, NULL, dn_incoming, &ndn_incoming, NULL);
+       dnNormalize(0, NULL, NULL, dn_stored, &ndn_stored, NULL);
        
        i = dnIsSuffix(&ndn_incoming, &ndn_stored);
        
index 06d448166a4534ad7f9adcf9a5ac20782ececf99..c42aa6e0f6574400b029d74472f9dbf204044169 100644 (file)
 #ifdef LDAP_CACHING 
 static int
 remove_func (
-       Backend         *be,
-       Connection      *conn,
        Operation       *op,
-       Entry           *entry,
-       AttributeName   *attrs,
-       int             attrsonly,
-       LDAPControl     **ctrls
+       SlapReply       *rs
 );
  
 struct query_info {
@@ -56,22 +51,22 @@ struct query_info {
    
 int 
 remove_query_data (
-       Backend* be,
-       Connection* conn, 
+       Operation       *op,
+       SlapReply       *rs,
        struct berval* query_uuid, 
        struct exception* result)
 {
-       struct query_info info; 
-       char filter_str[64]; 
-       Operation op = {0};
-       Filterfilter; 
-       struct timeval time_in; 
-       struct timeval time_out; 
-       long timediff; 
-
-       slap_callback cb = {callback_null_response, 
-                       callback_null_sresult, remove_func, NULL}; 
-       sprintf(filter_str, "(queryid=%s)", query_uuid->bv_val);
+       struct query_info       info; 
+       char                    filter_str[64]; 
+       Operation               op_tmp = *op;
+       Filter                  *filter; 
+       struct timeval          time_in; 
+       struct timeval          time_out; 
+       long timediff;
+
+       slap_callback cb = { remove_func, NULL }; 
+       snprintf(filter_str, sizeof(filter_str), "(queryid=%s)",
+                       query_uuid->bv_val);
        filter = str2filter(filter_str);              
        info.uuid = query_uuid; 
        info.freed = 0; 
@@ -79,48 +74,53 @@ remove_query_data (
        info.err = SUCCESS; 
        cb.sc_private = &info; 
  
-       op.o_tag = LDAP_REQ_SEARCH;
-       op.o_protocol = LDAP_VERSION3;
-       op.o_ndn = conn->c_ndn;
-       op.o_callback = &cb;
-       op.o_time = slap_get_time();
-       op.o_do_not_cache = 1;
-       op.o_caching_on = 1; 
-       be->be_search( be, conn, &op, NULL, &(be->be_nsuffix[0]),
-                       LDAP_SCOPE_SUBTREE, LDAP_DEREF_NEVER, 0, 0,
-                       filter, NULL, NULL, 0 );
+       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_caching_on = 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, rs );
+
        result->type = info.err;  
        result->rc = info.deleted; 
+
        return info.freed;  
 }
 
 static int
 remove_func (
-       Backend         *be,
-       Connection      *conn,
        Operation       *op,
-       Entry           *entry,
-       AttributeName   *attrs,
-       int             attrsonly,
-       LDAPControl     **ctrls
+       SlapReply       *rs
 )
 {
-       slap_callback   *tmp = op->o_callback;  
-       struct query_info* info = tmp->sc_private; 
-#if 0  /* ??? pdn is not used anywhere */
-       struct berval pdn; 
-#endif
-       int count = 0; 
-       int size; 
-       struct timeval time_in; 
-       struct timeval time_out; 
-       long timediff; 
-       Modifications* mod; 
+       struct query_info       *info = op->o_callback->sc_private;
+       int                     count = 0;
+       int                     size;
+       struct timeval          time_in;
+       struct timeval          time_out;
+       long                    timediff;
+       Modifications           *mod;
+
+       Attribute               *attr;
+       Operation               op_tmp = *op;
 
-       Attribute* attr; 
-       size = get_entry_size(entry, 0, NULL);  
+       size = get_entry_size(rs->sr_entry, 0, NULL);
 
-       for (attr = entry->e_attrs; attr!= NULL; attr = attr->a_next) {
+       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++) 
                                ;
@@ -133,9 +133,6 @@ remove_func (
                return 0; 
        }
        if (count == 1) {
-#if 0  /* ??? pdn is not used anywhere */
-               dnPretty(NULL, &entry->e_nname, &pdn);  
-#endif
                info->freed += size; 
 #ifdef NEW_LOGGING
                LDAP_LOG( BACK_META, DETAIL1,
@@ -146,7 +143,10 @@ remove_func (
                                size, attr->a_vals[0].bv_val, 0 );
 #endif
 
-               if (be->be_delete (be, conn, op, &entry->e_name, &entry->e_nname)) {
+               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++; 
@@ -172,9 +172,15 @@ remove_func (
        Debug( LDAP_DEBUG_ANY, "REMOVING TEMP ATTR : TEMPLATE=%s\n",
                        attr->a_vals[0].bv_val, 0, 0 );
 #endif
-       if (be->be_modify(be, conn, op, &(entry->e_name), &(entry->e_nname), mod)) {
+
+       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, rs )) {
                info->err = REMOVE_ERR;
        }
+
        info->freed += LDIF_SIZE_NEEDED(9, (strlen(info->uuid->bv_val))); 
 
        return 0;
index 2f25c95e6d96a8b7e1a1401adaae4a8f49a15eb0..88ab760039d9c1bf98720195e4e36d98e9f20190 100644 (file)
@@ -122,12 +122,11 @@ is_one_level_rdn(
 
 static struct metaconn*  
 metaConnect(
-       struct metainfo* li, 
-       Connection* conn, 
-       Operation* op, 
-       int op_type, 
-       struct berval* nbase, 
-       struct exception* result 
+       Operation               *op, 
+       SlapReply               *rs,
+       int                     op_type, 
+       struct berval           *nbase, 
+       struct exception        *result 
 );
 
 static void
@@ -141,6 +140,7 @@ static int
 handleLdapResult(
        struct metaconn* lc, 
        Operation* op, 
+       SlapReply *rs,
        int* msgid, Backend* be, 
        AttributeName* attrs, 
        int attrsonly, 
@@ -188,10 +188,10 @@ attrscmp(
 
 static char* 
 cache_entries(
+       Operation       *op,
+       SlapReply       *rs,
        Entry** entry_array, 
        cache_manager* cm, 
-       Backend* be, 
-       Connection* conn, 
        struct exception* result
 ); 
 
@@ -205,24 +205,22 @@ is_temp_answerable(
 
 static void
 consistency_check(
-       Backend* be,
-       Backend* glue_be, 
-       Connection* conn
+       Operation       *op,
+       SlapReply       *rs,
+       Backend         *glue_be
 ); 
 
 static int
 cache_back_sentry(
-       Backend* be, 
-       Connection* conn,
        Operation* op, 
-       Entry* e, 
-       AttributeName* attrs, 
-       int attrsonly, 
-       LDAPControl** ctrls
+       SlapReply *rs
 );
 
 int
 meta_back_cache_search(
+       Operation       *op,
+       SlapReply       *rs )
+       /*
        Backend         *be,
        Connection      *conn,
        Operation       *op,
@@ -236,9 +234,9 @@ meta_back_cache_search(
        struct berval   *filterstr,
        AttributeName   *attributes,
        int             attrsonly
-)
+) */
 {
-       struct metainfo         *li = ( struct metainfo * )be->be_private;
+       struct metainfo         *li = ( struct metainfo * )op->o_bd->be_private;
        struct metaconn         *lc;
        struct metasingleconn   *lsc;
        cache_manager*          cm = li->cm; 
@@ -279,20 +277,20 @@ meta_back_cache_search(
    
        struct exception result[1]; 
 
-       Filter* filter = str2filter(filterstr->bv_val); 
-       slap_callback cb = {NULL, NULL, cache_back_sentry, NULL}; 
+       Filter* filter = str2filter(op->ors_filterstr.bv_val); 
+       slap_callback cb = {cache_back_sentry, NULL}; 
 
-       cb.sc_private = be
+       cb.sc_private = op->o_bd
 
-       if (attributes) {
-               for ( count=0; attributes[ count ].an_name.bv_val; count++ )
+       if (op->ors_attrs) {
+               for ( count=0; op->ors_attrs[ count ].an_name.bv_val; count++ )
                        ;
                attrs = (AttributeName*)malloc( ( count + 1 ) *
                                                sizeof(AttributeName));
-               for ( count=0; attributes[ count ].an_name.bv_val; count++ ) {
+               for ( count=0; op->ors_attrs[ count ].an_name.bv_val; count++ ) {
                        ber_dupbv(&attrs[ count ].an_name,
-                                               &attributes[ count ].an_name);
-                       attrs[count].an_desc = attributes[count].an_desc; 
+                                               &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;
@@ -327,8 +325,8 @@ meta_back_cache_search(
     
        query.filter = filter; 
        query.attrs = attrs; 
-       query.base = *base
-       query.scope = scope; 
+       query.base = op->o_req_dn
+       query.scope = op->ors_scope; 
 
        /* check for query containment */
        if (attr_set > -1) {
@@ -343,10 +341,10 @@ meta_back_cache_search(
 #ifdef NEW_LOGGING
                        LDAP_LOG( BACK_META, DETAIL2,
                                        "Entering QC, querystr = %s\n",
-                                       filterstr->bv_val, 0, 0 );
+                                       op->ors_filterstr.bv_val, 0, 0 );
 #else /* !NEW_LOGGING */
                        Debug( LDAP_DEBUG_NONE, "Entering QC, querystr = %s\n",
-                                               filterstr->bv_val, 0, 0 );
+                                       op->ors_filterstr.bv_val, 0, 0 );
 #endif /* !NEW_LOGGING */
                        answerable = (*(qm->qcfunc))(qm, &query, i);
 
@@ -356,32 +354,41 @@ meta_back_cache_search(
        }
 
        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", base->bv_val,
-                                       conn, &cbase, result); 
+               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 = *base;
+                       cachebase = op->o_req_dn;
                } else {
                        cachebase.bv_val = cbase;
                        cachebase.bv_len = strlen(cbase);
                }
-               dnNormalize(NULL, &cachebase, &ncachebase); 
-       
-               op->o_caching_on = 1;   
-               op->o_callback = &cb; 
-               li->glue_be->be_search(li->glue_be, conn, op, &cachebase,
-                               &ncachebase, scope, deref, slimit, tlimit,
-                               filter, filterstr, attrs, attrsonly);
+               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_caching_on = 1; 
+               op_tmp.o_callback = &cb; 
+
+               li->glue_be->be_search(op, rs);
                ber_memfree( ncachebase.bv_val );
-               if ( cachebase.bv_val != base->bv_val ) {
+               if ( cachebase.bv_val != op->o_req_dn.bv_val ) {
                        /* free only if rewritten */
                        free( cachebase.bv_val );
                }
@@ -395,13 +402,14 @@ meta_back_cache_search(
                Debug( LDAP_DEBUG_ANY, "QUERY NOT ANSWERABLE\n", 0, 0, 0 );
 #endif /* !NEW_LOGGING */
 
-               if ( scope == LDAP_SCOPE_BASE ) {
+               if ( op->ors_scope == LDAP_SCOPE_BASE ) {
                        op_type = META_OP_REQUIRE_SINGLE;
                } else {
                        op_type = META_OP_ALLOW_MULTIPLE;
                }
 
-               lc = metaConnect(li, conn, op, op_type, nbase, result);
+               lc = metaConnect(op, rs, op_type,
+                               &op->o_req_ndn, result);
 
                if (result->type != SUCCESS) 
                        goto Catch; 
@@ -447,38 +455,39 @@ meta_back_cache_search(
                 */
 
                for ( i = 0, lsc = lc->conns; !META_LAST(lsc); ++i, ++lsc ) {
-                       char    *realbase = ( char * )base->bv_val;
-                       int     realscope = scope;
+                       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, nbase ))
+                                       &li->targets[i]->suffix,
+                                       &op->o_req_ndn ))
                                lsc->candidate = META_CANDIDATE; 
 
                        if ( lsc->candidate != META_CANDIDATE ) 
                                continue;
 
-                       if ( deref != -1 ) {
+                       if ( op->ors_deref != -1 ) {
                                ldap_set_option( lsc->ld, LDAP_OPT_DEREF,
-                                               ( void * )&deref);
+                                               ( void * )&op->ors_deref);
                        }
-                       if ( tlimit != -1 ) {
+                       if ( op->ors_tlimit != -1 ) {
                                ldap_set_option( lsc->ld, LDAP_OPT_TIMELIMIT,
-                                               ( void * )&tlimit);
+                                               ( void * )&op->ors_tlimit);
                        }
-                       if ( slimit != -1 ) {
+                       if ( op->ors_slimit != -1 ) {
                                ldap_set_option( lsc->ld, LDAP_OPT_SIZELIMIT,
-                                               ( void * )&slimit);
+                                               ( void * )&op->ors_slimit);
                        }
 
                        /*
                         * modifies the base according to the scope, if required
                         */
                        suffixlen = li->targets[ i ]->suffix.bv_len;
-                       if ( suffixlen > nbase->bv_len ) {
-                               switch ( scope ) {
+                       if ( suffixlen > op->o_req_ndn.bv_len ) {
+                               switch ( op->ors_scope ) {
                                case LDAP_SCOPE_SUBTREE:
                                        /*
                                         * make the target suffix the new base
@@ -488,7 +497,7 @@ meta_back_cache_search(
                                         */
                                        if ( dnIsSuffix(
                                                &li->targets[ i ]->suffix,
-                                               nbase ) ) {
+                                               &op->o_req_ndn ) ) {
                                                realbase =
                                                li->targets[i]->suffix.bv_val;
                                        } else {
@@ -505,10 +514,10 @@ meta_back_cache_search(
                                case LDAP_SCOPE_ONELEVEL:
                                        if ( is_one_level_rdn(
                                                li->targets[ i ]->suffix.bv_val,
-                                               suffixlen - nbase->bv_len - 1 )
+                                               suffixlen - op->o_req_ndn.bv_len - 1 )
                                                && dnIsSuffix(
                                                &li->targets[ i ]->suffix,
-                                               nbase ) ) {
+                                               &op->o_req_ndn ) ) {
                                                /*
                                                 * if there is exactly one
                                                 * level, make the target suffix
@@ -520,6 +529,7 @@ meta_back_cache_search(
                                                realscope = LDAP_SCOPE_BASE;
                                                break;
                                        } /* else continue with the next case */
+
                                case LDAP_SCOPE_BASE:
                                        /*
                                         * this target is no longer candidate
@@ -533,8 +543,9 @@ meta_back_cache_search(
                         * Rewrite the search base, if required
                         */
 
-                       rewriteSession(li->targets[i]->rwinfo, "searchBase",
-                                       realbase, conn, &mbase, result); 
+                       rewriteSession(li->targets[i]->rwmap.rwm_rw,
+                                       "searchBase",
+                                       realbase, op->o_conn, &mbase, result); 
 
                        if (result->type != SUCCESS)
                                goto Catch; 
@@ -546,8 +557,9 @@ meta_back_cache_search(
                        /*
                         * Rewrite the search filter, if required
                         */
-                       rewriteSession( li->targets[i]->rwinfo, "searchFilter",
-                                       filterstr->bv_val, conn,
+                       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; 
@@ -559,19 +571,20 @@ meta_back_cache_search(
                                if ( mfilter.bv_val != NULL ) {
                                        free( mfilter.bv_val );
                                }
-                               mfilter = *filterstr;
+                               mfilter = op->ors_filterstr;
                        }
 
                        /*
                         * Maps attributes in filter
                         */
                        mapped_filter = ldap_back_map_filter(
-                                       &li->targets[i]->at_map,
-                                       &li->targets[i]->oc_map, &mfilter, 0 );
+                                       &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 != filterstr->bv_val ) {
+                               if ( mfilter.bv_val != op->ors_filterstr.bv_val ) {
                                        free( mfilter.bv_val );
                                }
                        }
@@ -581,23 +594,10 @@ meta_back_cache_search(
                        /*
                         * Maps required attributes
                         */
-                       mapped_attrs = ldap_back_map_attrs(
-                                       &li->targets[ i ]->at_map,
-                                       new_attrs, 0 );
-                       if ( mapped_attrs == NULL && new_attrs) {
-                               for ( count=0;
-                                     new_attrs[ count ].an_name.bv_val;
-                                     count++)
-                                       ;
-                               mapped_attrs = ch_malloc( ( count + 1 ) *
-                                                       sizeof(char *));
-                               for ( count=0;
-                                     new_attrs[ count ].an_name.bv_val;
-                                     count++ ) {
-                                       mapped_attrs[ count ] =
-                                               new_attrs[count].an_name.bv_val;
-                               }
-                               mapped_attrs[ count ] = NULL;
+                       if ( ldap_back_map_attrs(
+                                       &li->targets[ i ]->rwmap.rwm_at,
+                                       new_attrs, 0, &mapped_attrs ) ) {
+                               goto Catch;
                        }
 
                        /*
@@ -605,7 +605,7 @@ meta_back_cache_search(
                         */
                        msgid[ i ] = ldap_search( lsc->ld, mbase, realscope,
                                                mapped_filter, mapped_attrs,
-                                               attrsonly ); 
+                                               op->ors_attrsonly ); 
                        if ( msgid[ i ] == -1 ) {
                                lsc->candidate = META_NOT_CANDIDATE;
                                continue;
@@ -616,7 +616,7 @@ meta_back_cache_search(
                                mapped_attrs = NULL;
                        }
 
-                       if ( mapped_filter != filterstr->bv_val ) {
+                       if ( mapped_filter != op->ors_filterstr.bv_val ) {
                                free( mapped_filter );
                                mapped_filter = NULL;
                        }
@@ -629,29 +629,36 @@ meta_back_cache_search(
                        ++candidates;
                }
 
-               num_entries = handleLdapResult(lc, op, msgid, be, attrs,
-                               attrsonly, candidates, cacheable, &entry_array,
-                               curr_limit, slimit, result); 
+               num_entries = handleLdapResult(lc, op, 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)) {
+                       Operation       op_tmp = *op;
+
 #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 */
-                       uuid = cache_entries(entry_array, cm, li->glue_be,
-                                                       conn, result); 
+                       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",
-                                       filterstr->bv_val, uuid, num_entries );
+                                       op->ors_filterstr.bv_val,
+                                       uuid, num_entries );
 #else /* !NEW_LOGGING */
                        Debug( LDAP_DEBUG_ANY,
                                        "Added query %s UUID %s ENTRIES %d\n",
-                                       filterstr->bv_val, uuid, num_entries );
+                                       op->ors_filterstr.bv_val,
+                                       uuid, num_entries );
 #endif /* !NEW_LOGGING */
            
                        if (result->type != SUCCESS) 
@@ -667,8 +674,9 @@ meta_back_cache_search(
 Catch:;
        switch (result->type) {
                case SUCCESS: 
-                       rc=0; 
-                       break; 
+                       rc = 0; 
+                       break;
+
                case FILTER_ERR: 
 #ifdef NEW_LOGGING
                        LDAP_LOG( BACK_META, DETAIL1,
@@ -678,6 +686,7 @@ Catch:;
                                        0, 0, 0 );
 #endif /* !NEW_LOGGING */
                        break; 
+
                case CONN_ERR: 
                        rc = -1; 
 #ifdef NEW_LOGGING
@@ -689,10 +698,10 @@ Catch:;
                                "Could not connect to a remote server\n",
                                0, 0, 0 );
 #endif /* !NEW_LOGGING */
-                       send_ldap_result(conn, op, LDAP_OTHER,  
-                                       NULL, "Connection error",
-                                       NULL, NULL );
-                       break; 
+                       send_ldap_error(op, rs, LDAP_OTHER,
+                                       "Connection error" );
+                       break;
+                       
                case RESULT_ERR: 
                        rc = -1; 
 #ifdef NEW_LOGGING
@@ -703,19 +712,19 @@ Catch:;
                                "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_result( conn, op,
+                               send_ldap_error( op, rs,
                                                LDAP_UNWILLING_TO_PERFORM,
-                                               NULL, "Unwilling to perform",
-                                               NULL, NULL );
+                                               "Unwilling to perform" );
                        } else {
-                               send_ldap_result( conn, op, LDAP_OTHER,
-                                               NULL, "Rewrite error",
-                                               NULL, NULL );
+                               send_ldap_error( op, rs, LDAP_OTHER,
+                                               "Rewrite error" );
                        }
-                       break; 
+                       break;
+
                case MERGE_ERR: 
                        rc = -1; 
 #ifdef NEW_LOGGING
@@ -725,7 +734,8 @@ Catch:;
                        Debug( LDAP_DEBUG_ANY,
                                "Error in merging entry \n", 0, 0, 0 );
 #endif /* !NEW_LOGGING */
-                       break; 
+                       break;
+
                case REMOVE_ERR: 
                        rc = -1; 
 #ifdef NEW_LOGGING
@@ -736,7 +746,8 @@ Catch:;
                        Debug( LDAP_DEBUG_ANY, "Error in removing query \n",
                                        0, 0, 0 );
 #endif /* !NEW_LOGGING */
-                       break; 
+                       break;
+
                default:
                        /* assert(0); */
                        break;
@@ -746,7 +757,7 @@ Catch:;
        curr_time = slap_get_time(); 
        if (curr_time - cm->consistency_time > cm->consistency_cycle_time) {
                cm->consistency_time = curr_time; 
-               consistency_check(be, li->glue_be, conn); 
+               consistency_check(op, rs, li->glue_be); 
        }       
        ldap_pvt_thread_mutex_unlock(&cm->consistency_mutex); 
 
@@ -812,7 +823,7 @@ meta_create_entry (
        /*
         * Rewrite the dn of the result, if needed
         */
-       rewriteSession( li->targets[ target ]->rwinfo, "searchResult",
+       rewriteSession( li->targets[ target ]->rwmap.rwm_rw, "searchResult",
                        bdn.bv_val, lc->conn, &ent->e_name.bv_val, result );  
 
        if (result->type != SUCCESS) {
@@ -840,7 +851,7 @@ meta_create_entry (
         * 
         * FIXME: should we log anything, or delegate to dnNormalize?
         */
-       dnNormalize( 0, NULL, NULL, &ent->e_name, &ent->e_nname ); 
+       dnNormalize( 0, NULL, NULL, &ent->e_name, &ent->e_nname, NULL ); 
 
        /*
        if ( dnNormalize( 0, NULL, NULL, &ent->e_name, &ent->e_nname )
@@ -865,7 +876,8 @@ meta_create_entry (
        attrp = &ent->e_attrs;
 
        while ( ber_scanf( &ber, "{m", &a ) != LBER_ERROR ) {
-               ldap_back_map( &li->targets[ target ]->at_map, &a, &mapped, 1 );
+               ldap_back_map( &li->targets[ target ]->rwmap.rwm_at, 
+                               &a, &mapped, 1 );
                if ( mapped.bv_val == NULL ) {
                        continue;
                }
@@ -909,7 +921,7 @@ meta_create_entry (
                        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]->oc_map,
+                               ldap_back_map( &li->targets[ target]->rwmap.rwm_oc,
                                                bv, &mapped, 1 );
                                if ( mapped.bv_val == NULL ) {
                                        free( bv->bv_val );
@@ -941,7 +953,7 @@ meta_create_entry (
                        int i;
                        for ( i = 0, bv = attr->a_vals; bv->bv_val; bv++,i++ ) {
                                char *newval;
-                               rewriteSession(li->targets[ target ]->rwinfo,
+                               rewriteSession(li->targets[ target ]->rwmap.rwm_rw,
                                                "searchResult", bv->bv_val,
                                                lc->conn, &newval, result); 
                                if (result->type != SUCCESS) {
@@ -995,16 +1007,16 @@ is_one_level_rdn(
 
 static struct metaconn*  
 metaConnect(
-       struct metainfo* li, 
-       Connection* conn, 
-       Operation* op, 
-       int op_type, 
-       struct berval* nbase, 
-       struct exception* result)
+       Operation*              op, 
+       SlapReply               *rs,
+       int                     op_type, 
+       struct berval           *nbase, 
+       struct exception        *result)
 {
-       struct metaconn* lc; 
+       struct metaconn         *lc; 
+
        result->type = SUCCESS; 
-       lc = meta_back_getconn( conn, op, op_type, nbase, NULL );
+       lc = meta_back_getconn( op, rs, op_type, nbase, NULL );
        if (!lc) {
                result->type = CONN_ERR; 
                return 0; 
@@ -1082,6 +1094,7 @@ static int
 handleLdapResult(
        struct metaconn* lc,
        Operation* op, 
+       SlapReply *rs,
        int* msgid, Backend* be, 
        AttributeName* attrs, 
        int attrsonly, 
@@ -1126,9 +1139,10 @@ handleLdapResult(
                        }
 
                        if ((entry = get_result_entry(be, lc, lsc,
-                                               msgid, i, &tv, result))) { 
-                               send_search_entry( be, lc->conn, op, entry,
-                                               attrs, attrsonly, NULL );
+                                               msgid, i, &tv, result))) {
+                               rs->sr_entry = entry;
+                               send_search_entry( op, rs );
+                               rs->sr_entry = NULL;
                                if ((cacheable) &&
                                                (num_entries < curr_limit))  {
                                        rewriteSession( li->rwinfo,
@@ -1164,7 +1178,8 @@ handleLdapResult(
                        } else if (result->rc == -1) {
                                break; 
                        } else {
-                               sres = ldap_back_map_result(result->rc);
+                               rs->sr_err = result->rc;
+                               sres = ldap_back_map_result(rs);
                                if (mres == LDAP_SUCCESS &&
                                                sres != LDAP_SUCCESS) {
                                        mres = sres; 
@@ -1188,9 +1203,10 @@ handleLdapResult(
                        Debug( LDAP_DEBUG_ANY, "ldap_result error, rc = -1\n",
                                        0, 0, 0 );
 #endif /* !NEW_LOGGING */
-                       send_search_result( lc->conn, op, LDAP_OTHER, NULL,
-                                       NULL, NULL, NULL, num_entries );
+                       rs->sr_err = LDAP_OTHER;
+                       send_ldap_result( op, rs );
                        return 0; 
+
                case CREATE_ENTRY_ERR: 
 #ifdef NEW_LOGGING
                        LDAP_LOG( BACK_META, DETAIL1,
@@ -1200,10 +1216,11 @@ handleLdapResult(
                        Debug( LDAP_DEBUG_ANY, "Error in parsing result \n",
                                        0, 0, 0 );
 #endif /* !NEW_LOGGING */
-                       send_search_result( lc->conn, op, LDAP_OTHER, NULL,
-                                       NULL, NULL, NULL, num_entries );
+                       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",
@@ -1212,11 +1229,11 @@ handleLdapResult(
                        Debug( LDAP_DEBUG_ANY, "Size limit exceeded \n",
                                        0, 0, 0 );
 #endif /* !NEW_LOGGING */
-                       send_search_result( lc->conn, op,
-                                       LDAP_SIZELIMIT_EXCEEDED,
-                                       NULL, NULL, NULL, NULL, num_entries );
+                       rs->sr_err = LDAP_SIZELIMIT_EXCEEDED;
+                       send_ldap_result( op, rs );
                        result->type = RESULT_ERR; 
-                       return 0; 
+                       return 0;
+
                case ABANDON_ERR: 
 #ifdef NEW_LOGGING
                        LDAP_LOG( BACK_META, DETAIL1,
@@ -1228,6 +1245,7 @@ handleLdapResult(
 #endif /* !NEW_LOGGING */
                        result->type = RESULT_ERR; 
                        return 0; 
+
                default:
                        /* assert( 0 ); */
                        break;
@@ -1242,8 +1260,14 @@ handleLdapResult(
                }
        }
 
-       send_search_result( lc->conn, op, mres, match, err,
-                               NULL, NULL, num_entries );
+       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); 
@@ -1417,21 +1441,21 @@ attrscmp(
 
 static char* 
 cache_entries(
+       Operation       *op,
+       SlapReply       *rs,
        Entry** entry_array, 
        cache_manager* cm, 
-       Backend* be, 
-       Connection* conn, 
        struct exception* result)
 {
-       int i; 
-       int return_val; 
-       int cache_size; 
-       Entrye; 
-       struct berval query_uuid; 
-       struct berval crp_uuid; 
-       char uuidbuf[ LDAP_LUTIL_UUIDSTR_BUFSIZE ], *crpid; 
-       char crpuuid[40]; 
-       query_managerqm = cm->qm;
+       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)); 
@@ -1476,7 +1500,7 @@ cache_entries(
                                                "Removing query UUID %s\n",
                                                crpuuid, 0, 0 );
 #endif /* !NEW_LOGGING */
-                                       return_val = remove_query_data(be, conn,
+                                       return_val = remove_query_data(op, rs,
                                                        &crp_uuid, result); 
 #ifdef NEW_LOGGING
                                        LDAP_LOG( BACK_META, DETAIL1,
@@ -1521,7 +1545,10 @@ cache_entries(
                                }
                        }
                }
-               return_val = merge_entry(be, conn, e, &query_uuid, result);
+
+               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,
@@ -1607,9 +1634,9 @@ is_temp_answerable(
 }
 
 static void 
-consistency_check(Backend* be, Backend* glue_be, Connection* conn)
+consistency_check(Operation *op, SlapReply *rs, Backend* glue_be)
 {
-       struct metainfo *li = ( struct metainfo * )be->be_private;
+       struct metainfo *li = ( struct metainfo * )op->o_bd->be_private;
        cache_manager*  cm = li->cm; 
        query_manager* qm = cm->qm; 
        CachedQuery* query, *query_prev; 
@@ -1617,8 +1644,10 @@ consistency_check(Backend* be, Backend* glue_be, Connection* conn)
        struct berval uuid;  
        struct exception result; 
        int i, return_val; 
-       QueryTemplate* templ; 
-    
+       QueryTemplate* templ;
+       Backend         *be = op->o_bd;
+
+       op->o_bd = glue_be;
       
        for (i=0; qm->templates[i].querystr; i++) {
                templ = qm->templates + i; 
@@ -1656,8 +1685,7 @@ consistency_check(Backend* be, Backend* glue_be, Connection* conn)
                        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(glue_be, conn,
-                                               &uuid, &result); 
+                       return_val = remove_query_data(op, rs, &uuid, &result); 
 #ifdef NEW_LOGGING
                        LDAP_LOG( BACK_META, DETAIL1,
                                        "STALE QUERY REMOVED, SIZE=%d\n",
@@ -1696,42 +1724,42 @@ consistency_check(Backend* be, Backend* glue_be, Connection* conn)
                }
                ldap_pvt_thread_mutex_unlock(&cm->remove_mutex); 
        }
+
+       op->o_bd = be;
 }
 
 static int
 cache_back_sentry(
-       Backend* glue_be, 
-       Connection* conn,
        Operation* op, 
-       Entry* e, 
-       AttributeName* attrs, 
-       int attrsonly, 
-       LDAPControl** ctrls )
+       SlapReply *rs )
 { 
-       slap_callback* cb = op->o_callback; 
-       Backend* be = (Backend*)(cb->sc_private); 
-       struct metainfo *li = ( struct metainfo * )be->be_private;
+       slap_callback           *cb = op->o_callback; 
+       struct metainfo         *li = ( struct metainfo * )op->o_bd->be_private;
  
-       char* ename = NULL; 
-       struct exception result; 
-       struct berval dn; 
-       struct berval ndn; 
+       char                    *ename = NULL;
+       struct exception        result;
+       struct berval           dn;
+       struct berval           ndn;
 
-       dn = e->e_name; 
-       ndn = e->e_nname; 
+       dn = rs->sr_entry->e_name; 
+       ndn = rs->sr_entry->e_nname; 
 
-       rewriteSession( li->rwinfo,
-               "cacheReturn", e->e_name.bv_val, conn, &ename, &result );  
-       ber_str2bv(ename, strlen(ename), 0, &e->e_name); 
-       ber_dupbv(&e->e_nname, &e->e_name); 
+       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(be, conn, op, e, attrs, attrsonly, ctrls); 
+
+       send_search_entry( op, rs );
  
-       e->e_name = dn; 
-       e->e_nname = ndn; 
+       rs->sr_entry->e_name = dn; 
+       rs->sr_entry->e_nname = ndn; 
 
        op->o_callback = cb; 
+
        return 0;  
 }
 #endif
index fc8621d6551e8d26b61d2d4f06de34db0d9d17bb..aa2bd16e33c0b53b1dd5293e9ee2273b23231b24 100644 (file)
@@ -154,19 +154,8 @@ typedef struct cache_manager_s {
 /* search-cache.c */
 int
 meta_back_cache_search(
-    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
+    SlapReply          *rs
 ); 
 
 /* config-cache.c */
@@ -203,11 +192,11 @@ filter2template( Filter *f,
 /* merge.c */
 
 int
-merge_entry (Backend* be,
-           Connection* conn
-           Entry* e, 
-           struct bervalquery_uuid, 
-           struct exceptionresult
+merge_entry (
+           Operation           *op
+           SlapReply           *rs,
+           struct berval       *query_uuid, 
+           struct exception    *result
 ); 
 
 int 
@@ -216,35 +205,11 @@ get_entry_size(Entry* e,
               struct exception* result
 ); 
 
-void 
-callback_null_response( Connection *conn, 
-                      Operation *o, 
-                      ber_tag_t tag,
-                      ber_int_t msgid, 
-                      ber_int_t err, 
-                      const char *matched,
-                      const char *text, 
-                      BerVarray ref, 
-                      const char *resoid,
-                      struct berval *resdata, 
-                      struct berval *sasldata, 
-                      LDAPControl **c
-);
-
-void callback_null_sresult( Connection *conn, 
-                          Operation *o, 
-                          ber_int_t err,
-                          const char *matched, 
-                          const char *text, 
-                          BerVarray refs, 
-                          LDAPControl **c,
-                          int nentries
-); 
-
 /* remove.c */
 int 
-remove_query_data (Backend* be,
-                  Connection* conn, 
+remove_query_data (
+                  Operation* conn,
+                  SlapReply *rs,
                   struct berval* query_uuid, 
                   struct exception* result
 );
index 0479735c7f70daf6cd1826bd8e8c6d87965a3fe2..6ac2a91e5f6a0ad700b3a159ee5c454af56ba99a 100644 (file)
@@ -118,16 +118,7 @@ meta_back_search( Operation *op, SlapReply *rs )
        cache_manager*  cm = li->cm;
 
        if (cm->caching) {
-               return meta_back_cache_search(op->o_bd, op->o_conn, op,
-                               &op->o_req_dn, &op->o_req_ndn, 
-                               op->oq_search.rs_scope,
-                               op->oq_search.rs_deref,
-                               op->oq_search.rs_slimit,
-                               op->oq_search.rs_tlimit,
-                               op->oq_search.rs_filter,
-                               &op->oq_search.rs_filterstr,
-                               op->oq_search.rs_attrs,
-                               op->oq_search.rs_attrsonly); 
+               return meta_back_cache_search(op, rs);
        }
 #endif /* LDAP_CACHING */