]> git.sur5r.net Git - openldap/commitdiff
ITS#6752 Handle REP_ENTRY_* flags correctly
authorHallvard Furuseth <hallvard@openldap.org>
Mon, 20 Dec 2010 10:22:19 +0000 (10:22 +0000)
committerHallvard Furuseth <hallvard@openldap.org>
Mon, 20 Dec 2010 10:22:19 +0000 (10:22 +0000)
servers/slapd/overlays/dynlist.c

index a5abe6fda823aeab8db4300a10da40d8edf8af0f..74e2d170a5d8e741926abf36400c4f98f8628d46 100644 (file)
@@ -364,7 +364,7 @@ done:;
        if ( rs->sr_flags & REP_ENTRY_MUSTBEFREED ) {
                entry_free( rs->sr_entry );
                rs->sr_entry = NULL;
-               rs->sr_flags ^= REP_ENTRY_MUSTBEFREED;
+               rs->sr_flags &= ~REP_ENTRY_MASK;
        }
 
        return 0;
@@ -379,7 +379,6 @@ dynlist_prepare_entry( Operation *op, SlapReply *rs, dynlist_info_t *dli )
        SlapReply       r = { REP_SEARCH };
        struct berval   *url;
        Entry           *e;
-       slap_mask_t     e_flags;
        int             opattrs,
                        userattrs;
        dynlist_sc_t    dlc = { 0 };
@@ -428,13 +427,11 @@ dynlist_prepare_entry( Operation *op, SlapReply *rs, dynlist_info_t *dli )
                o.o_groups = NULL;
        }
 
-       e_flags = rs->sr_flags;
+       e = rs->sr_entry;
+       /* ensure e is modifiable, but do not replace
+        * sr_entry yet since we have pointers into it */
        if ( !( rs->sr_flags & REP_ENTRY_MODIFIABLE ) ) {
                e = entry_dup( rs->sr_entry );
-               e_flags |= ( REP_ENTRY_MODIFIABLE | REP_ENTRY_MUSTBEFREED );
-               e_flags &= ~REP_ENTRY_MUSTRELEASE;
-       } else {
-               e = rs->sr_entry;
        }
 
        dlc.dlc_e = e;
@@ -630,8 +627,10 @@ cleanup:;
                ldap_free_urldesc( lud );
        }
 
-       rs->sr_entry = e;
-       rs->sr_flags = e_flags;
+       if ( e != rs->sr_entry ) {
+               rs_replace_entry( op, rs, (slap_overinst *)op->o_bd->bd_info, e );
+               rs->sr_flags |= REP_ENTRY_MODIFIABLE | REP_ENTRY_MUSTBEFREED;
+       }
 
        return SLAP_CB_CONTINUE;
 }