]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/overlays/rwm.c
in op_response, rearrange contextCSN update checks
[openldap] / servers / slapd / overlays / rwm.c
index de8da75f3ef32141ed766647434662e5217d75d7..09675bb004765641aa4facee11d98b7207354699 100644 (file)
@@ -823,7 +823,7 @@ rwm_entry_release_rw( Operation *op, Entry *e, int rw )
        }
 
        /* just free entry if (probably) ours */
-       if ( e->e_private == NULL ) {
+       if ( e->e_private == NULL && BER_BVISNULL( &e->e_bv ) ) {
                entry_free( e );
                return LDAP_SUCCESS;
        }
@@ -847,6 +847,7 @@ rwm_entry_get_rw( Operation *op, struct berval *ndn,
        SlapReply               rs = { REP_SEARCH };
 
        rwm_op_state            ros = { 0 };
+       struct berval           mndn = BER_BVNULL;
 
        if ( ((BackendInfo *)on->on_info->oi_orig)->bi_entry_get_rw == NULL ) {
                return SLAP_CB_CONTINUE;
@@ -862,6 +863,8 @@ rwm_entry_get_rw( Operation *op, struct berval *ndn,
                return LDAP_OTHER;
        }
 
+       mndn = BER_BVISNULL( &ros.r_ndn ) ? *ndn : ros.r_ndn;
+
        /* map attribute & objectClass */
        if ( at != NULL ) {
        }
@@ -874,8 +877,10 @@ rwm_entry_get_rw( Operation *op, struct berval *ndn,
        op2.o_bd = &db;
        op2.o_bd->bd_info = (BackendInfo *)on->on_info->oi_orig;
        op2.ors_attrs = slap_anlist_all_attributes;
-       rc = op2.o_bd->bd_info->bi_entry_get_rw( &op2, &ros.r_ndn, oc, at, rw, ep );
+       rc = op2.o_bd->bd_info->bi_entry_get_rw( &op2, &mndn, oc, at, rw, ep );
        if ( rc == LDAP_SUCCESS && *ep != NULL ) {
+               /* we assume be_entry_release() needs to be called */
+               rs.sr_flags = REP_ENTRY_MUSTRELEASE;
                rs.sr_entry = *ep;
 
                /* duplicate & release */
@@ -887,7 +892,7 @@ rwm_entry_get_rw( Operation *op, struct berval *ndn,
                }
        }
 
-       if ( ros.r_ndn.bv_val != ndn->bv_val ) {
+       if ( !BER_BVISNULL( &ros.r_ndn) && ros.r_ndn.bv_val != ndn->bv_val ) {
                op->o_tmpfree( ros.r_ndn.bv_val, op->o_tmpmemctx );
        }