]> git.sur5r.net Git - openldap/commitdiff
ITS#4991 pcache and rwm interaction
authorRalf Haferkamp <ralf@openldap.org>
Wed, 13 Jun 2007 16:28:11 +0000 (16:28 +0000)
committerRalf Haferkamp <ralf@openldap.org>
Wed, 13 Jun 2007 16:28:11 +0000 (16:28 +0000)
servers/slapd/overlays/pcache.c
servers/slapd/overlays/rwm.c

index 15230af780fa0b9fdd09a7db6bebf2d36697f4e4..8fa9449c21e9b63170d27b08252b74bdeff95449 100644 (file)
@@ -1025,6 +1025,18 @@ cache_entries(
        return return_val;
 }
 
+static int
+pcache_op_cleanup( Operation *op, SlapReply *rs ) {
+       slap_callback   *cb = op->o_callback;
+       struct search_info *si = cb->sc_private;
+       if ( si->query.save_attrs != NULL ) {
+               rs->sr_attrs = si->query.save_attrs;
+               op->ors_attrs = si->query.save_attrs;
+       }
+       op->o_callback = op->o_callback->sc_next;
+       op->o_tmpfree( cb, op->o_tmpmemctx );
+}
+
 static int
 pcache_response(
        Operation       *op,
@@ -1097,8 +1109,7 @@ pcache_response(
                        filter_free( si->query.filter );
                }
 
-               /* free self */
-               op->o_callback->sc_cleanup = slap_freeself_cb;
+               op->o_callback->sc_cleanup = pcache_op_cleanup;
        }
        return SLAP_CB_CONTINUE;
 }
index bbd83b186537ab66c4b7d2c9480d3d3dbb4b339d..f65e75a393d8ed90d4ba559ab2a910034132bb79 100644 (file)
@@ -32,6 +32,7 @@ typedef struct rwm_op_state {
        struct berval ro_ndn;
        struct berval r_dn;
        struct berval r_ndn;
+       AttributeName *mapped_attrs;
        OpRequest o_request;
 } rwm_op_state;
 
@@ -79,7 +80,7 @@ rwm_op_cleanup( Operation *op, SlapReply *rs )
                        }
                        break;
                case LDAP_REQ_SEARCH:
-                       ch_free( op->ors_attrs );
+                       ch_free( ros->mapped_attrs );
                        filter_free_x( op, op->ors_filter );
                        ch_free( op->ors_filterstr.bv_val );
                        op->ors_attrs = ros->ors_attrs;
@@ -770,6 +771,11 @@ rwm_swap_attrs( Operation *op, SlapReply *rs )
        rwm_op_state *ros = cb->sc_private;
 
        rs->sr_attrs = ros->ors_attrs;
+
+       /* other overlays might have touched op->ors_attrs, 
+        * so we restore the original version here, otherwise
+        * attribute-mapping might fail */
+       op->ors_attrs = ros->mapped_attrs; 
        
        return SLAP_CB_CONTINUE;
 }
@@ -844,6 +850,9 @@ rwm_op_search( Operation *op, SlapReply *rs )
        }
 
        op->ors_attrs = an;
+       /* store the mapped Attributes for later usage, in
+        * the case that other overlays change op->ors_attrs */
+       roc->ros.mapped_attrs = an;
        roc->cb.sc_response = rwm_swap_attrs;
 
        op->o_callback = &roc->cb;