]> git.sur5r.net Git - openldap/commitdiff
ITS#6758 Use rs_*() to manage SlapReply entries.
authorHallvard Furuseth <hallvard@openldap.org>
Fri, 31 Dec 2010 17:55:36 +0000 (17:55 +0000)
committerHallvard Furuseth <hallvard@openldap.org>
Fri, 31 Dec 2010 17:55:36 +0000 (17:55 +0000)
Some noop changes + fixes entry leaks and REP_ENTRY_MODIFIABLE flag leaks.

contrib/slapd-modules/cloak/cloak.c
contrib/slapd-modules/usn/usn.c
servers/slapd/overlays/collect.c
servers/slapd/overlays/pcache.c
servers/slapd/overlays/syncprov.c
servers/slapd/overlays/translucent.c
servers/slapd/overlays/valsort.c
servers/slapd/result.c
servers/slapd/slapi/slapi_pblock.c

index 03c9c09f9121638114dbeae955480a57320df4a3..b6746e9ce86ea355a90db67c1a2c7c53d23bd95f 100644 (file)
@@ -221,10 +221,8 @@ cloak_search_cb( Operation *op, SlapReply *rs )
        /*
         * We are now committed to cloak an attribute.
         */
-       if ( rs->sr_flags & REP_ENTRY_MODIFIABLE )
-               me = e;
-       else
-               me = entry_dup( e );
+       rs_ensure_entry_modifiable( op, rs, (slap_overinst *) op->o_bd->bd_info );
+       me = rs->sr_entry;
                
        for ( ci = (cloak_info_t *)sc->sc_private; ci; ci = ci->ci_next ) {
                Attribute *a;
@@ -251,14 +249,6 @@ cloak_search_cb( Operation *op, SlapReply *rs )
 
        }
 
-       if ( me != e ) {
-               if ( rs->sr_flags & REP_ENTRY_MUSTBEFREED )
-                       entry_free( e );
-
-               rs->sr_entry = me;
-               rs->sr_flags |= REP_ENTRY_MODIFIABLE | REP_ENTRY_MUSTBEFREED;
-       }
-
        return ( SLAP_CB_CONTINUE );
 }
 
index bbf09c5cbb845170cb8b89c4d1819140e3ddb96b..cb622eb780d475c0ee5179fd012d267b070359ea 100644 (file)
@@ -135,10 +135,7 @@ usn_operational(
                                }
 
                        if ( !ap ) {
-                               if ( !rs->sr_flags & REP_ENTRY_MODIFIABLE ) {
-                                       rs->sr_entry = entry_dup( rs->sr_entry );
-                                       rs->sr_flags |=
-                                               REP_ENTRY_MODIFIABLE|REP_ENTRY_MUSTBEFREED;
+                               if ( rs_ensure_entry_modifiable( op,rs, on )) {
                                        a = attr_find( rs->sr_entry->e_attrs,
                                                ad_usnChanged );
                                }
index 48fec67cb95caf042d219664ddb5718c158ceb3f..6c9a2651111aaee276d219384ea3d3c96c93d323 100644 (file)
@@ -386,19 +386,7 @@ collect_response( Operation *op, SlapReply *rs )
                        * don't modify it directly. Make a copy and
                        * work with that instead.
                        */
-                       if ( !( rs->sr_flags & REP_ENTRY_MODIFIABLE ) ) {
-                               Entry *e;
-
-                               e = entry_dup( rs->sr_entry );
-                               if ( rs->sr_flags & REP_ENTRY_MUSTRELEASE ) {
-                                       overlay_entry_release_ov( op, rs->sr_entry, 0, on );
-                                       rs->sr_flags &= ~REP_ENTRY_MUSTRELEASE;
-                               } else if ( rs->sr_flags & REP_ENTRY_MUSTBEFREED ) {
-                                       entry_free( rs->sr_entry );
-                               }
-                               rs->sr_entry = e;
-                               rs->sr_flags |= REP_ENTRY_MODIFIABLE|REP_ENTRY_MUSTBEFREED;
-                       }
+                       rs_ensure_entry_modifiable( op, rs, on );
 
                        /* Loop for each attribute in this collectinfo */
                        for(idx=0; idx<ci->ci_ad_num; idx++) {
index e584e435d90242148568e31c903a7464ab8dc63a..c5f2100f961ad621ea1eb15310336e24b9a8c770 100644 (file)
@@ -2030,11 +2030,7 @@ fetch_queryId_cb( Operation *op, SlapReply *rs )
        }
 
        /* clear entry if required */
-       if ( rs->sr_flags & REP_ENTRY_MUSTBEFREED ) {
-               entry_free( rs->sr_entry );
-               rs->sr_entry = NULL;
-               rs->sr_flags ^= REP_ENTRY_MUSTBEFREED;
-       }
+       rs_flush_entry( op, rs, (slap_overinst *) op->o_bd->bd_info );
 
        return rc;
 }
index 6f8fb7f3380cce0d2f370380a9f13a4de0822f16..3834dd5a6d05f96e1ede4f7ed86879b65f9fe08c 100644 (file)
@@ -2740,17 +2740,7 @@ syncprov_operational(
                                }
 
                                if ( !ap ) {
-                                       if ( !(rs->sr_flags & REP_ENTRY_MODIFIABLE) ) {
-                                               Entry *e = entry_dup( rs->sr_entry );
-                                               if ( rs->sr_flags & REP_ENTRY_MUSTRELEASE ) {
-                                                       overlay_entry_release_ov( op, rs->sr_entry, 0, on );
-                                                       rs->sr_flags ^= REP_ENTRY_MUSTRELEASE;
-                                               } else if ( rs->sr_flags & REP_ENTRY_MUSTBEFREED ) {
-                                                       entry_free( rs->sr_entry );
-                                               }
-                                               rs->sr_entry = e;
-                                               rs->sr_flags |=
-                                                       REP_ENTRY_MODIFIABLE|REP_ENTRY_MUSTBEFREED;
+                                       if ( rs_ensure_entry_modifiable( op, rs, on )) {
                                                a = attr_find( rs->sr_entry->e_attrs,
                                                        slap_schema.si_ad_contextCSN );
                                        }
index 2b07607898076403a9ccc49b9a41ba34efbaf617..9ba368da985b09c022a71a0277ea59acd59aa60d 100644 (file)
@@ -815,14 +815,7 @@ static int translucent_search_cb(Operation *op, SlapReply *rs) {
                if ( tc->step & USE_LIST ) {
                        re = tavl_delete( &tc->list, le, entry_dn_cmp );
                        if ( re ) {
-                               if ( rs->sr_flags & REP_ENTRY_MUSTRELEASE ) {
-                                       rs->sr_flags ^= REP_ENTRY_MUSTRELEASE;
-                                       overlay_entry_release_ov( op, rs->sr_entry, 0, on );
-                               }
-                               if ( rs->sr_flags & REP_ENTRY_MUSTBEFREED ) {
-                                       rs->sr_flags ^= REP_ENTRY_MUSTBEFREED;
-                                       entry_free( rs->sr_entry );
-                               }
+                               rs_flush_entry( op, rs, on );
                                rc = test_filter( op, re, tc->orig );
                                if ( rc == LDAP_COMPARE_TRUE ) {
                                        rs->sr_flags |= REP_ENTRY_MUSTBEFREED;
@@ -855,14 +848,7 @@ static int translucent_search_cb(Operation *op, SlapReply *rs) {
                rc = overlay_entry_get_ov(op, &rs->sr_entry->e_nname, NULL, NULL, 0, &le, on);
                if ( rc == LDAP_SUCCESS && le ) {
                        re = entry_dup( rs->sr_entry );
-                       if ( rs->sr_flags & REP_ENTRY_MUSTRELEASE ) {
-                               rs->sr_flags ^= REP_ENTRY_MUSTRELEASE;
-                               overlay_entry_release_ov( op, rs->sr_entry, 0, on );
-                       }
-                       if ( rs->sr_flags & REP_ENTRY_MUSTBEFREED ) {
-                               rs->sr_flags ^= REP_ENTRY_MUSTBEFREED;
-                               entry_free( rs->sr_entry );
-                       }
+                       rs_flush_entry( op, rs, on );
                } else {
                        le = NULL;
                }
@@ -902,14 +888,7 @@ static int translucent_search_cb(Operation *op, SlapReply *rs) {
                }
                /* Dispose of local entry */
                if ( tc->step & LCL_SIDE ) {
-                       if ( rs->sr_flags & REP_ENTRY_MUSTRELEASE ) {
-                               rs->sr_flags ^= REP_ENTRY_MUSTRELEASE;
-                               overlay_entry_release_ov( op, rs->sr_entry, 0, on );
-                       }
-                       if ( rs->sr_flags & REP_ENTRY_MUSTBEFREED ) {
-                               rs->sr_flags ^= REP_ENTRY_MUSTBEFREED;
-                               entry_free( rs->sr_entry );
-                       }
+                       rs_flush_entry(op, rs, on);
                } else {
                        overlay_entry_release_ov(op, le, 0, on);
                }
index e516e46269141b19efced616cf4e2be34c16cab7..a64f189242384dc0e0c8076c133aba15519b6284 100644 (file)
@@ -297,20 +297,7 @@ valsort_response( Operation *op, SlapReply *rs )
                a = attr_find( rs->sr_entry->e_attrs, vi->vi_ad );
                if ( !a ) continue;
 
-               if (( rs->sr_flags & ( REP_ENTRY_MODIFIABLE|REP_ENTRY_MUSTBEFREED ) ) !=
-                       ( REP_ENTRY_MODIFIABLE|REP_ENTRY_MUSTBEFREED ) )
-               {
-                       Entry *e;
-
-                       e = entry_dup( rs->sr_entry );
-                       if ( rs->sr_flags & REP_ENTRY_MUSTRELEASE ) {
-                               overlay_entry_release_ov( op, rs->sr_entry, 0, on );
-                               rs->sr_flags &= ~REP_ENTRY_MUSTRELEASE;
-                       } else if ( rs->sr_flags & REP_ENTRY_MUSTBEFREED ) {
-                               entry_free( rs->sr_entry );
-                       }
-                       rs->sr_entry = e;
-                       rs->sr_flags |= REP_ENTRY_MODIFIABLE|REP_ENTRY_MUSTBEFREED;
+               if ( rs_ensure_entry_modifiable( op, rs, on )) {
                        a = attr_find( rs->sr_entry->e_attrs, vi->vi_ad );
                }
 
index 1f6a2f3fc867255e322fb0e549622ddbbfbd6b3a..e70ac54c08acfe62f8a670cbee3246d181cbee66 100644 (file)
@@ -1407,13 +1407,10 @@ error_return:;
         * should set it back so that the cleanup functions know
         * what they're doing.
         */
-       if ( op->o_tag == LDAP_REQ_SEARCH && rs->sr_type == REP_SEARCH 
-               && rs->sr_entry 
-               && ( rs->sr_flags & REP_ENTRY_MUSTBEFREED ) ) 
-       {
-               entry_free( rs->sr_entry );
-               rs->sr_entry = NULL;
-               rs->sr_flags &= ~REP_ENTRY_MUSTBEFREED;
+       if ( op->o_tag == LDAP_REQ_SEARCH && rs->sr_type == REP_SEARCH ) {
+               rs_flush_entry( op, rs, NULL );
+       } else {
+               RS_ASSERT( (rs->sr_flags & REP_ENTRY_MASK) == 0 );
        }
 
        if ( rs->sr_flags & REP_CTRLS_MUSTBEFREED ) {
index bbc91d4a4ed2cae6b5c3d97d5b58ce49fbf77651..31b0dc35667577c7a5d114622d3004bc0348e71b 100644 (file)
@@ -1176,13 +1176,8 @@ pblock_set( Slapi_PBlock *pb, int param, void *value )
                break;
        case SLAPI_SEARCH_RESULT_ENTRY:
                PBLOCK_ASSERT_OP( pb, 0 );
-               if ( pb->pb_rs->sr_flags & REP_ENTRY_MUSTBEFREED ) {
-                       entry_free( pb->pb_rs->sr_entry );
-               } else if ( pb->pb_rs->sr_flags & REP_ENTRY_MUSTRELEASE ) {
-                       be_entry_release_r( pb->pb_op, pb->pb_rs->sr_entry );
-                       pb->pb_rs->sr_flags ^= REP_ENTRY_MUSTRELEASE;
-               }
-               pb->pb_rs->sr_entry = (Slapi_Entry *)value;
+               rs_replace_entry( pb->pb_op, pb->pb_rs, NULL, (Slapi_Entry *)value );
+               /* TODO: Should REP_ENTRY_MODIFIABLE be set? */
                pb->pb_rs->sr_flags |= REP_ENTRY_MUSTBEFREED;
                break;
        case SLAPI_BIND_RET_SASLCREDS:
@@ -1429,4 +1424,3 @@ slapi_int_pblock_get_next( Slapi_PBlock **pb )
 }
 
 #endif /* LDAP_SLAPI */
-