]> git.sur5r.net Git - openldap/commitdiff
ITS#6758 Avoid SlapReply reuse, simple cases.
authorHallvard Furuseth <hallvard@openldap.org>
Fri, 31 Dec 2010 10:46:22 +0000 (10:46 +0000)
committerHallvard Furuseth <hallvard@openldap.org>
Fri, 31 Dec 2010 10:46:22 +0000 (10:46 +0000)
Caller provides and reuses a SlapReply it does not read after
initialization.  So reinitialize or move the declaration inwards.
In case of refint, move the rs parameter into refint_repair().

12 files changed:
contrib/slapd-modules/addpartial/addpartial-overlay.c
contrib/slapd-modules/autogroup/autogroup.c
servers/slapd/bconfig.c
servers/slapd/connection.c
servers/slapd/overlays/accesslog.c
servers/slapd/overlays/constraint.c
servers/slapd/overlays/dynlist.c
servers/slapd/overlays/memberof.c
servers/slapd/overlays/pcache.c
servers/slapd/overlays/refint.c
servers/slapd/overlays/syncprov.c
servers/slapd/syncrepl.c

index 8cc099c2d015da12dfac0a82ab10766517182479..824e9a0570a558fce2a42a54a335f7e7b1228bb7 100644 (file)
@@ -43,7 +43,6 @@ static slap_overinst addpartial;
 static int addpartial_add( Operation *op, SlapReply *rs)
 {
     Operation nop = *op;
-    SlapReply nrs = { REP_RESULT };
     Entry *toAdd = NULL;
     Entry *found = NULL;
     slap_overinst *on = (slap_overinst *) op->o_bd->bd_info;
@@ -258,12 +257,6 @@ static int addpartial_add( Operation *op, SlapReply *rs)
                 Debug(LDAP_DEBUG_TRACE, "%s: mods to do...\n",
                       addpartial.on_bi.bi_type, 0, 0);
 
-                memset(&nrs, 0, sizeof(nrs));
-                nrs.sr_type = REP_RESULT;
-                nrs.sr_err = LDAP_SUCCESS;
-                nrs.sr_entry = NULL;
-                nrs.sr_text = NULL;
-
                 nop.o_tag = LDAP_REQ_MODIFY;
                 nop.orm_modlist = mods;
                 nop.orm_no_opattrs = 0;
@@ -281,6 +274,7 @@ static int addpartial_add( Operation *op, SlapReply *rs)
 
                 if(nop.o_bd->be_modify)
                 {
+                    SlapReply nrs = { REP_RESULT };
                     rc = (nop.o_bd->be_modify)(&nop, &nrs);
                 }
 
index a71a083473d620de295f84b158e1c32e04290899..97fd28f77d483f7f35bd44c8414fbddb19d49f44 100644 (file)
@@ -448,6 +448,8 @@ autogroup_add_members_from_filter( Operation *op, Entry *e, autogroup_entry_t *a
        o.o_bd->bd_info = (BackendInfo *)on;    
 
        if ( modify == 1 && agg.agg_mod ) {
+               rs_reinit( &rs, REP_RESULT );
+
                o = *op;
                o.o_callback = &null_cb;
                o.o_tag = LDAP_REQ_MODIFY;
@@ -1703,7 +1705,6 @@ autogroup_db_open(
        autogroup_def_t         *agd;
        autogroup_sc_t          ags;
        Operation               *op;
-       SlapReply               rs = { REP_RESULT };
        slap_callback           cb = { 0 };
 
        void                            *thrctx = ldap_pvt_thread_pool_context();
@@ -1746,6 +1747,7 @@ autogroup_db_open(
        op->o_callback = &cb;
 
        for (agd = agi->agi_def ; agd ; agd = agd->agd_next) {
+               SlapReply       rs = { REP_RESULT };
 
                autogroup_build_def_filter(agd, op);
 
index 5b4e37b91739e4a11a7eddb0769b182372e8e119..7a3e18a2b95d9ffe57d19de9848892fc22e1c4a1 100644 (file)
@@ -4193,10 +4193,12 @@ config_setup_ldif( BackendDB *be, const char *dir, int readit ) {
 
                op->o_tag = LDAP_REQ_ADD;
                if ( rc == LDAP_SUCCESS && sc.frontend ) {
+                       rs_reinit( &rs, REP_RESULT );
                        op->ora_e = sc.frontend;
                        rc = op->o_bd->be_add( op, &rs );
                }
                if ( rc == LDAP_SUCCESS && sc.config ) {
+                       rs_reinit( &rs, REP_RESULT );
                        op->ora_e = sc.config;
                        rc = op->o_bd->be_add( op, &rs );
                }
@@ -6866,8 +6868,10 @@ config_back_db_open( BackendDB *be, ConfigReply *cr )
                        return -1;
                }
                ce = e->e_private;
-               if ( be->be_cf_ocs && be->be_cf_ocs->co_cfadd )
+               if ( be->be_cf_ocs && be->be_cf_ocs->co_cfadd ) {
+                       rs_reinit( &rs, REP_RESULT );
                        be->be_cf_ocs->co_cfadd( op, &rs, e, &c );
+               }
                /* Iterate through overlays */
                if ( oi ) {
                        slap_overinst *on;
@@ -6906,8 +6910,10 @@ config_back_db_open( BackendDB *be, ConfigReply *cr )
                                if ( !oe ) {
                                        return -1;
                                }
-                               if ( c.bi->bi_cf_ocs && c.bi->bi_cf_ocs->co_cfadd )
+                               if ( c.bi->bi_cf_ocs && c.bi->bi_cf_ocs->co_cfadd ) {
+                                       rs_reinit( &rs, REP_RESULT );
                                        c.bi->bi_cf_ocs->co_cfadd( op, &rs, oe, &c );
+                               }
                        }
                }
        }
index 43832ba7cafcb8ec7005b85c0c25bc5fd1a39630..12dbb7c1fbbd99d0f47ed566aab8a8a4e8c35f99 100644 (file)
@@ -702,7 +702,6 @@ static void connection_abandon( Connection *c )
 
        Operation *o, *next, op = {0};
        Opheader ohdr = {0};
-       SlapReply rs = {0};
 
        op.o_hdr = &ohdr;
        op.o_conn = c;
@@ -710,6 +709,8 @@ static void connection_abandon( Connection *c )
        op.o_tag = LDAP_REQ_ABANDON;
 
        for ( o = LDAP_STAILQ_FIRST( &c->c_ops ); o; o=next ) {
+               SlapReply rs = {REP_RESULT};
+
                next = LDAP_STAILQ_NEXT( o, o_next );
                op.orn_msgid = o->o_msgid;
                o->o_abandon = 1;
index 4f4bbafafa9341e7daa34299098d4616508d1462..542ad193f070821e64d5e16efe1f4351af309975 100644 (file)
@@ -669,8 +669,10 @@ accesslog_purge( void *ctx, void *arg )
                for (i=0; i<pd.used; i++) {
                        op->o_req_dn = pd.dn[i];
                        op->o_req_ndn = pd.ndn[i];
-                       if ( !slapd_shutdown )
+                       if ( !slapd_shutdown ) {
+                               rs_reinit( &rs, REP_RESULT );
                                op->o_bd->be_delete( op, &rs );
+                       }
                        ch_free( pd.ndn[i].bv_val );
                        ch_free( pd.dn[i].bv_val );
                }
@@ -680,6 +682,7 @@ accesslog_purge( void *ctx, void *arg )
                {
                        Modifications mod;
                        struct berval bv[2];
+                       rs_reinit( &rs, REP_RESULT );
                        /* update context's entryCSN to reflect oldest CSN */
                        mod.sml_numvals = 1;
                        mod.sml_values = bv;
index 9027dbb6b91305b1533074eb42d962ca90390903..fcb2830ee88cbf2e45d344ba3537fdfac10ee36e 100644 (file)
@@ -556,7 +556,6 @@ constraint_violation( constraint *c, struct berval *bv, Operation *op )
                Operation nop = *op;
                slap_overinst *on = (slap_overinst *) op->o_bd->bd_info;
                slap_callback cb;
-               SlapReply nrs = { REP_RESULT };
                int i;
                int found = 0;
                int rc;
@@ -640,6 +639,8 @@ constraint_violation( constraint *c, struct berval *bv, Operation *op )
                        rc = LDAP_OTHER;
 
                } else {
+                       SlapReply nrs = { REP_RESULT };
+
                        Debug(LDAP_DEBUG_TRACE, 
                                "==> constraint_violation uri filter = %s\n",
                                filterstr.bv_val, 0, 0);
index c9a2427e30de833e464a3d3ebaf01598544e9644..67db47817a570ba0a5f23733b235b136e7d699d1 100644 (file)
@@ -348,7 +348,6 @@ dynlist_prepare_entry( Operation *op, SlapReply *rs, dynlist_info_t *dli )
        Attribute       *a, *id = NULL;
        slap_callback   cb;
        Operation       o = *op;
-       SlapReply       r = { REP_SEARCH };
        struct berval   *url;
        Entry           *e;
        int             opattrs,
@@ -564,6 +563,7 @@ dynlist_prepare_entry( Operation *op, SlapReply *rs, dynlist_info_t *dli )
                
                o.o_bd = select_backend( &o.o_req_ndn, 1 );
                if ( o.o_bd && o.o_bd->be_search ) {
+                       SlapReply       r = { REP_SEARCH };
                        r.sr_attr_flags = slap_attr_flags( o.ors_attrs );
                        (void)o.o_bd->be_search( &o, &r );
                }
index 1771febb1e6540d2d4e50f0f85bdd101ec796a60..4fa3946973cdbd8f34ac331c6b55553a6004ee0f 100644 (file)
@@ -243,7 +243,6 @@ memberof_isGroupOrMember( Operation *op, memberof_cbinfo_t *mci )
        memberof_t              *mo = (memberof_t *)on->on_bi.bi_private;
 
        Operation               op2 = *op;
-       SlapReply               rs2 = { REP_RESULT };
        slap_callback           cb = { 0 };
        BackendInfo     *bi = op->o_bd->bd_info;
        AttributeName           an[ 2 ];
@@ -276,6 +275,8 @@ memberof_isGroupOrMember( Operation *op, memberof_cbinfo_t *mci )
        op2.ors_tlimit = SLAP_NO_LIMIT;
 
        if ( mci->what & MEMBEROF_IS_GROUP ) {
+               SlapReply       rs2 = { REP_RESULT };
+
                mc.ad = mo->mo_ad_member;
                mc.foundit = 0;
                mc.vals = NULL;
@@ -296,6 +297,8 @@ memberof_isGroupOrMember( Operation *op, memberof_cbinfo_t *mci )
        }
 
        if ( mci->what & MEMBEROF_IS_MEMBER ) {
+               SlapReply       rs2 = { REP_RESULT };
+
                mc.ad = mo->mo_ad_memberof;
                mc.foundit = 0;
                mc.vals = NULL;
index 7efbff133e1f46fab2a69cfa215ffdfb4d5ebcb3..6a4af3bc30719fa12e1664de660cc1072d8c6edf 100644 (file)
@@ -863,6 +863,7 @@ merge_entry(
 
        if ( rc != LDAP_SUCCESS ) {
                if ( rc == LDAP_ALREADY_EXISTS ) {
+                       rs_reinit( &sreply, REP_RESULT );
                        slap_entry2mods( e, &modlist, &text, textbuf, textlen );
                        modlist->sml_op = LDAP_MOD_ADD;
                        op->o_tag = LDAP_REQ_MODIFY;
@@ -1788,6 +1789,7 @@ remove_query_data(
 
                op->o_req_dn = qi->xdn;
                op->o_req_ndn = qi->xdn;
+               rs_reinit( &sreply, REP_RESULT );
 
                if ( qi->del ) {
                        Debug( pcache_debug, "DELETING ENTRY TEMPLATE=%s\n",
@@ -2051,7 +2053,6 @@ pcache_remove_entries_from_cache(
        OperationBuffer opbuf;
        Operation       op2;
        slap_callback   sc = { 0 };
-       SlapReply       rs = { REP_RESULT };
        Filter          f = { 0 };
        char            filtbuf[ LDAP_LUTIL_UUIDSTR_BUFSIZE + STRLENOF( "(entryUUID=)" ) ];
        AttributeAssertion ava = ATTRIBUTEASSERTION_INIT;
@@ -2098,6 +2099,7 @@ pcache_remove_entries_from_cache(
 
        for ( s = 0; !BER_BVISNULL( &entryUUIDs[ s ] ); s++ ) {
                BerVarray       vals = NULL;
+               SlapReply       rs = { REP_RESULT };
 
                op->ors_filterstr.bv_len = snprintf( filtbuf, sizeof( filtbuf ),
                        "(entryUUID=%s)", entryUUIDs[ s ].bv_val );
index 063bd5c3443a21fdc014d7303c66c35d04ffbc0e..cc5335b6a27487f2943382c89885f8a0d2b28c0c 100644 (file)
@@ -521,11 +521,11 @@ refint_search_cb(
 static int
 refint_repair(
        Operation       *op,
-       SlapReply       *rs,
        refint_data     *id,
        refint_q        *rq )
 {
        dependent_data  *dp;
+       SlapReply               rs = {REP_RESULT};
        int             rc;
 
        op->o_callback->sc_response = refint_search_cb;
@@ -535,7 +535,7 @@ refint_repair(
        op->o_ndn = op->o_bd->be_rootndn;
 
        /* search */
-       rc = op->o_bd->be_search( op, rs );
+       rc = op->o_bd->be_search( op, &rs );
 
        if ( rc != LDAP_SUCCESS ) {
                Debug( LDAP_DEBUG_TRACE,
@@ -695,7 +695,6 @@ refint_qtask( void *ctx, void *arg )
        Connection conn = {0};
        OperationBuffer opbuf;
        Operation *op;
-       SlapReply rs = {REP_RESULT};
        slap_callback cb = { NULL, NULL, NULL, NULL };
        Filter ftop, *fptr;
        refint_q *rq;
@@ -772,7 +771,7 @@ refint_qtask( void *ctx, void *arg )
 
                if ( rq->db != NULL ) {
                        op->o_bd = rq->db;
-                       refint_repair( op, &rs, id, rq );
+                       refint_repair( op, id, rq );
 
                } else {
                        BackendDB       *be;
@@ -785,7 +784,7 @@ refint_qtask( void *ctx, void *arg )
 
                                if ( be->be_search && be->be_modify ) {
                                        op->o_bd = be;
-                                       refint_repair( op, &rs, id, rq );
+                                       refint_repair( op, id, rq );
                                }
                        }
                }
index 0dc00c9427a1c5fe9aafe530e34db1d7e8adbf08..6f8fb7f3380cce0d2f370380a9f13a4de0822f16 100644 (file)
@@ -735,6 +735,7 @@ again:
                        /* If we didn't find an exact match, then try for <= */
                        if ( findcsn_retry ) {
                                findcsn_retry = 0;
+                               rs_reinit( &frs, REP_RESULT );
                                goto again;
                        }
                        rc = LDAP_NO_SUCH_OBJECT;
@@ -1423,7 +1424,7 @@ syncprov_checkpoint( Operation *op, slap_overinst *on )
        syncprov_info_t *si = (syncprov_info_t *)on->on_bi.bi_private;
        Modifications mod;
        Operation opm;
-       SlapReply rsm = { 0 };
+       SlapReply rsm = {REP_RESULT};
        slap_callback cb = {0};
        BackendDB be;
        BackendInfo *bi;
@@ -1468,6 +1469,7 @@ syncprov_checkpoint( Operation *op, slap_overinst *on )
                char txtbuf[SLAP_TEXT_BUFLEN];
                size_t textlen = sizeof txtbuf;
                Entry *e = slap_create_context_csn_entry( opm.o_bd, NULL );
+               rs_reinit( &rsm, REP_RESULT );
                slap_mods2entry( &mod, &e, 0, 1, &text, txtbuf, textlen);
                opm.ora_e = e;
                opm.o_bd->be_add( &opm, &rsm );
@@ -1679,7 +1681,6 @@ syncprov_playlog( Operation *op, SlapReply *rs, sessionlog *sl,
 
        if ( mmods ) {
                Operation fop;
-               SlapReply frs = { REP_RESULT };
                int rc;
                Filter mf, af;
                AttributeAssertion eq = ATTRIBUTEASSERTION_INIT;
@@ -1710,11 +1711,11 @@ syncprov_playlog( Operation *op, SlapReply *rs, sessionlog *sl,
 
                for ( i=ndel; i<num; i++ ) {
                  if ( uuids[i].bv_len != 0 ) {
+                       SlapReply frs = { REP_RESULT };
 
                        mf.f_av_value = uuids[i];
                        cb.sc_private = NULL;
                        fop.ors_slimit = 1;
-                       frs.sr_nentries = 0;
                        rc = fop.o_bd->be_search( &fop, &frs );
 
                        /* If entry was not found, add to delete list */
index 0036638ff4ead3545a572318fc8d439da05c4401..4d5174fd67c173b5d4c232085ca0c402afb8c767 100644 (file)
@@ -2789,9 +2789,7 @@ syncrepl_del_nonpresent(
 {
        Backend* be = op->o_bd;
        slap_callback   cb = { NULL };
-       SlapReply       rs_search = {REP_RESULT};
        SlapReply       rs_delete = {REP_RESULT};
-       SlapReply       rs_modify = {REP_RESULT};
        struct nonpresent_entry *np_list, *np_prev;
        int rc;
        AttributeName   an[2];
@@ -2838,6 +2836,8 @@ syncrepl_del_nonpresent(
                si->si_refreshDelete |= NP_DELETE_ONE;
 
                for (i=0; uuids[i].bv_val; i++) {
+                       SlapReply rs_search = {REP_RESULT};
+
                        op->ors_slimit = 1;
                        uf.f_av_value = uuids[i];
                        filter2bv_x( op, op->ors_filter, &op->ors_filterstr );
@@ -2849,6 +2849,7 @@ syncrepl_del_nonpresent(
                Filter *cf, *of;
                Filter mmf[2];
                AttributeAssertion mmaa;
+               SlapReply rs_search = {REP_RESULT};
 
                memset( &an[0], 0, 2 * sizeof( AttributeName ) );
                an[0].an_name = slap_schema.si_ad_entryUUID->ad_cname;
@@ -2933,6 +2934,7 @@ syncrepl_del_nonpresent(
                                si->si_ridtxt, op->o_req_dn.bv_val, rc );
 
                        if ( rs_delete.sr_err == LDAP_NOT_ALLOWED_ON_NONLEAF ) {
+                               SlapReply rs_modify = {REP_RESULT};
                                Modifications mod1, mod2;
                                mod1.sml_op = LDAP_MOD_REPLACE;
                                mod1.sml_flags = 0;