]> git.sur5r.net Git - openldap/commitdiff
Consolidated slap_callbacks into one function. Removed send_search_result.
authorHoward Chu <hyc@openldap.org>
Tue, 1 Apr 2003 04:12:18 +0000 (04:12 +0000)
committerHoward Chu <hyc@openldap.org>
Tue, 1 Apr 2003 04:12:18 +0000 (04:12 +0000)
18 files changed:
servers/slapd/back-bdb/search.c
servers/slapd/back-ldap/search.c
servers/slapd/back-ldbm/search.c
servers/slapd/back-monitor/modify.c
servers/slapd/back-monitor/search.c
servers/slapd/back-passwd/search.c
servers/slapd/backglue.c
servers/slapd/connection.c
servers/slapd/proto-slap.h
servers/slapd/result.c
servers/slapd/sasl.c
servers/slapd/saslauthz.c
servers/slapd/search.c
servers/slapd/slap.h
servers/slapd/slapi/Makefile.in
servers/slapd/slapi/slapi_ops.c
servers/slapd/slapi/slapi_utils.c
servers/slapd/tools/mimic.c

index 5ba85e50ca0515b9fd53778367d3f9b452b75d5e..0ab656fac8727249c735090b6ca5d6a6fc47fb55 100644 (file)
@@ -68,12 +68,11 @@ bdb_cancel( Operation *op, SlapReply *rs )
 
 #if 0
                                bdb_build_sync_done_ctrl( conn, ps_list, ps_list->ctrls, 1, &latest_entrycsn_bv );
-                               send_search_result( conn, ps_list, LDAP_CANCELLED,
+                               send_ldap_result( conn, ps_list, LDAP_CANCELLED,
                                                NULL, NULL, NULL, ps_list->ctrls, ps_list->nentries);
 #endif
                                rs->sr_err = LDAP_CANCELLED;
-                               rs->sr_nentries = 0;
-                               send_search_result( ps_list, rs );
+                               send_ldap_result( ps_list, rs );
 
                                slap_op_free ( ps_list );
                                return LDAP_SUCCESS;
@@ -107,7 +106,7 @@ int bdb_search( Operation *op, SlapReply *rs )
        Entry   *matched = NULL;
        struct berval   realbase = { 0, NULL };
        int             manageDSAit;
-       int             nentries = 0, tentries = 0;
+       int             tentries = 0;
        ID              lastid = NOID;
        AttributeName   *attrs;
 
@@ -367,7 +366,7 @@ dn2entry_retry:
                        /* positive hard limit means abort */
                        } else if ( limit->lms_t_hard > 0 ) {
                                rs->sr_err = LDAP_ADMINLIMIT_EXCEEDED;
-                               send_search_result( sop, rs );
+                               send_ldap_result( sop, rs );
                                rs->sr_err = 0;
                                goto done;
                        }
@@ -394,7 +393,7 @@ dn2entry_retry:
                        /* positive hard limit means abort */
                        } else if ( limit->lms_s_hard > 0 ) {
                                rs->sr_err = LDAP_ADMINLIMIT_EXCEEDED;
-                               send_search_result( sop, rs );
+                               send_ldap_result( sop, rs );
                                rs->sr_err = 0; 
                                goto done;
                        }
@@ -456,7 +455,7 @@ dn2entry_retry:
 #endif
 
                rs->sr_err = LDAP_SUCCESS;
-               send_search_result( sop, rs );
+               send_ldap_result( sop, rs );
                rs->sr_err = 1;
                goto done;
        }
@@ -465,7 +464,7 @@ dn2entry_retry:
        if ( !isroot && limit->lms_s_unchecked != -1 ) {
                if ( BDB_IDL_N(candidates) > (unsigned) limit->lms_s_unchecked ) {
                        rs->sr_err = LDAP_ADMINLIMIT_EXCEEDED;
-                       send_search_result( sop, rs );
+                       send_ldap_result( sop, rs );
                        rs->sr_err = 1;
                        goto done;
                }
@@ -483,7 +482,7 @@ dn2entry_retry:
                        if ( sop->o_pagedresults_size == 0 ) {
                                rs->sr_err = LDAP_SUCCESS;
                                rs->sr_text = "search abandoned by pagedResult size=0";
-                               send_search_result( sop, rs );
+                               send_ldap_result( sop, rs );
                                goto done;
                        }
                        for ( id = bdb_idl_first( candidates, &cursor );
@@ -500,7 +499,6 @@ dn2entry_retry:
                                "bdb_search: no paged results candidates\n",
                                0, 0, 0 );
 #endif
-                       rs->sr_nentries = nentries;
                        send_pagerequest_response( sop, rs, lastid, 0 );
 
                        rs->sr_err = 1;
@@ -586,8 +584,7 @@ loop_begin:
                if ( sop->o_cancel ) {
                        assert( sop->o_cancel == SLAP_CANCEL_REQ );
                        rs->sr_err = LDAP_CANCELLED;
-                       rs->sr_nentries = nentries;
-                       send_search_result( sop, rs );
+                       send_ldap_result( sop, rs );
                        sop->o_cancel = SLAP_CANCEL_ACK;
                        rs->sr_err = 0;
                        goto done;
@@ -598,8 +595,7 @@ loop_begin:
                if ( sop->oq_search.rs_tlimit != -1 && slap_get_time() > stoptime ) {
                        rs->sr_err = LDAP_TIMELIMIT_EXCEEDED;
                        rs->sr_ref = rs->sr_v2ref;
-                       rs->sr_nentries = nentries;
-                       send_search_result( sop, rs );
+                       send_ldap_result( sop, rs );
                        goto done;
                }
 
@@ -828,15 +824,13 @@ id2entry_retry:
                                        rs->sr_entry = NULL;
                                        rs->sr_err = LDAP_SIZELIMIT_EXCEEDED;
                                        rs->sr_ref = rs->sr_v2ref;
-                                       rs->sr_nentries = nentries;
-                                       send_search_result( sop, rs );
+                                       send_ldap_result( sop, rs );
                                        goto done;
                                }
 
 #ifdef LDAP_CONTROL_PAGEDRESULTS
                                if ( get_pagedresults(sop) ) {
-                                       if ( nentries >= sop->o_pagedresults_size ) {
-                                               rs->sr_nentries = nentries;
+                                       if ( rs->sr_nentries >= sop->o_pagedresults_size ) {
                                                send_pagerequest_response( sop, rs,
                                                        lastid, tentries );
                                                goto done;
@@ -1001,7 +995,6 @@ id2entry_retry:
 
                                        switch (result) {
                                        case 0:         /* entry sent ok */
-                                               nentries++;
                                                break;
                                        case 1:         /* entry not sent */
                                                break;
@@ -1057,8 +1050,7 @@ loop_continue:
                rs->sr_ctrls = ctrls;
                rs->sr_ref = rs->sr_v2ref;
                rs->sr_err = (rs->sr_v2ref == NULL) ? LDAP_SUCCESS : LDAP_REFERRAL;
-               rs->sr_nentries = nentries;
-               send_search_result( sop, rs );
+               send_ldap_result( sop, rs );
 
                ch_free( latest_entrycsn_bv.bv_val );
                latest_entrycsn_bv.bv_val = NULL;
@@ -1084,8 +1076,7 @@ loop_continue:
                        rs->sr_ctrls = ctrls;
                        rs->sr_ref = rs->sr_v2ref;
                        rs->sr_err = (rs->sr_v2ref == NULL) ? LDAP_SUCCESS : LDAP_REFERRAL;
-                       rs->sr_nentries = nentries;
-                       send_search_result( sop, rs );
+                       send_ldap_result( sop, rs );
                        if ( ctrls[num_ctrls-1]->ldctl_value.bv_val != NULL )
                                ch_free( ctrls[num_ctrls-1]->ldctl_value.bv_val );
                        ch_free( ctrls[--num_ctrls] );
@@ -1100,8 +1091,7 @@ loop_continue:
                rs->sr_ctrls = NULL;
                rs->sr_ref = rs->sr_v2ref;
                rs->sr_err = (rs->sr_v2ref == NULL) ? LDAP_SUCCESS : LDAP_REFERRAL;
-               rs->sr_nentries = nentries;
-               send_search_result( sop, rs );
+               send_ldap_result( sop, rs );
        }
        }
 
@@ -1394,7 +1384,7 @@ send_pagerequest_response(
 
        rs->sr_ctrls = ctrls;
        rs->sr_err = LDAP_SUCCESS;
-       send_search_result( op, rs );
+       send_ldap_result( op, rs );
 
 done:
        (void) ber_free_buf( ber );
index 1ce5335e6ee52e5ed9190e107e9615db5e16d0d5..4c4399144a608b361e8aacb9c8657982dd26a899 100644 (file)
@@ -215,9 +215,7 @@ fail:;
         * but this is necessary for version matching, and for ACL processing.
         */
 
-       for (   rs->sr_nentries=0, rc=0;
-                       rc != -1;
-                       rc = ldap_result(lc->ld, msgid, 0, &tv, &res))
+       for ( rc=0; rc != -1; rc = ldap_result(lc->ld, msgid, 0, &tv, &res))
        {
                /* check for abandon */
                if (op->o_abandon) {
@@ -237,7 +235,6 @@ fail:;
                        e = ldap_first_entry(lc->ld,res);
                        if ( ldap_build_entry(op->o_bd, op->o_conn, e, &ent, &bdn, 1) == LDAP_SUCCESS ) {
                                Attribute *a;
-                               rs->sr_nentries++;
                                rs->sr_entry = &ent;
                                rs->sr_attrs = op->oq_search.rs_attrs;
                                send_search_entry( op, rs );
@@ -350,7 +347,7 @@ fail:;
        if ( rs->sr_v2ref ) {
                rs->sr_err = LDAP_REFERRAL;
        }
-       send_search_result( op, rs );
+       send_ldap_result( op, rs );
 
 finish:;
        if ( match ) {
index 62fdb4521a5be1b4d74eba46c79108c9eaa53d54..dc51c35318b8e9c36631dcb9b8719682d1ca796c 100644 (file)
@@ -40,7 +40,6 @@ ldbm_back_search(
        struct berval   realbase = { 0, NULL };
        int             manageDSAit = get_manageDSAit( op );
        int             cscope = LDAP_SCOPE_DEFAULT;
-       int             nentries = 0;
 
 #ifdef LDAP_CACHING
        Entry           cache_base_entry; 
@@ -221,7 +220,7 @@ searchit:
 #endif /* LDAP_CACHING */
 
                rs->sr_err = LDAP_SUCCESS;
-               send_search_result( op, rs );
+               send_ldap_result( op, rs );
 
 #ifdef LDAP_CACHING
                 if ( op->o_caching_on ) {
@@ -338,8 +337,7 @@ searchit:
                /* check time limit */
                if ( op->oq_search.rs_tlimit != -1 && slap_get_time() > stoptime ) {
                        rs->sr_err = LDAP_TIMELIMIT_EXCEEDED;
-                       rs->sr_nentries = nentries;
-                       send_search_result( op, rs );
+                       send_ldap_result( op, rs );
                        rc = 0;
                        goto done;
                }
@@ -494,8 +492,7 @@ searchit:
                                if ( --op->oq_search.rs_slimit == -1 ) {
                                        cache_return_entry_r( &li->li_cache, e );
                                        rs->sr_err = LDAP_SIZELIMIT_EXCEEDED;
-                                       rs->sr_nentries = nentries;
-                                       send_search_result( op, rs );
+                                       send_ldap_result( op, rs );
                                        rc = 0;
                                        goto done;
                                }
@@ -520,7 +517,6 @@ searchit:
 
                                        switch (result) {
                                        case 0:         /* entry sent ok */
-                                               nentries++;
                                                break;
                                        case 1:         /* entry not sent */
                                                break;
@@ -571,8 +567,7 @@ loop_continue:
 
        rs->sr_err = rs->sr_v2ref ? LDAP_REFERRAL : LDAP_SUCCESS;
        rs->sr_ref = rs->sr_v2ref;
-       rs->sr_nentries = nentries;
-       send_search_result( op, rs );
+       send_ldap_result( op, rs );
 
        rc = 0;
 
index a3d73d8f93923199fab15c72bca92f2b47b9083e..4383b7eaeec75a7792ab84ea6d16f5f84b1d1623 100644 (file)
@@ -70,7 +70,7 @@ monitor_back_modify( Operation *op, SlapReply *rs )
        if ( e == NULL ) {
                rs->sr_err = LDAP_NO_SUCH_OBJECT;
                if ( matched ) {
-                       rs->sr_matched = ch_strdup( matched->e_dn );
+                       rs->sr_matched = matched->e_name.bv_val;
                }
                send_ldap_result( op, rs );
                if ( matched != NULL ) {
index 2ea29d692ac0aed955e178ef7c098e225bc16030..0848ac9d291468040f742bae5e4ba5aaaa534c76 100644 (file)
@@ -55,15 +55,13 @@ monitor_send_children(
        Operation       *op,
        SlapReply       *rs,
        Entry           *e_parent,
-       int             sub,
-       int             *nentriesp
+       int             sub
 )
 {
        struct monitorinfo      *mi =
                (struct monitorinfo *) op->o_bd->be_private;
        Entry                   *e, *e_tmp, *e_ch;
        struct monitorentrypriv *mp;
-       int                     nentries;
        int                     rc;
 
        mp = ( struct monitorentrypriv * )e_parent->e_private;
@@ -106,7 +104,7 @@ monitor_send_children(
        }
 
        /* return entries */
-       for ( nentries = *nentriesp; e != NULL; ) {
+       for ( ; e != NULL; ) {
                mp = ( struct monitorentrypriv * )e->e_private;
 
                monitor_entry_update( mi, e );
@@ -115,12 +113,11 @@ monitor_send_children(
                if ( rc == LDAP_COMPARE_TRUE ) {
                        rs->sr_entry = e;
                        send_search_entry( op, rs );
-                       nentries++;
                }
 
                if ( ( mp->mp_children || MONITOR_HAS_VOLATILE_CH( mp ) )
                                && sub ) {
-                       rc = monitor_send_children( op, rs, e, sub, &nentries );
+                       rc = monitor_send_children( op, rs, e, sub );
                        if ( rc ) {
                                return( rc );
                        }
@@ -144,7 +141,6 @@ monitor_back_search( Operation *op, SlapReply *rs )
                = (struct monitorinfo *) op->o_bd->be_private;
        int             rc = LDAP_SUCCESS;
        Entry           *e, *matched = NULL;
-       int             nentries = 0;
 
 #ifdef NEW_LOGGING
        LDAP_LOG( BACK_MON, ENTRY,
@@ -169,7 +165,6 @@ monitor_back_search( Operation *op, SlapReply *rs )
                return( 0 );
        }
 
-       nentries = 0;
        switch ( op->oq_search.rs_scope ) {
        case LDAP_SCOPE_BASE:
                monitor_entry_update( mi, e );
@@ -177,14 +172,13 @@ monitor_back_search( Operation *op, SlapReply *rs )
                if ( rc == LDAP_COMPARE_TRUE ) {
                        rs->sr_entry = e;
                        send_search_entry( op, rs );
-                       nentries = 1;
                }
                rc = LDAP_SUCCESS;
                monitor_cache_release( mi, e );
                break;
 
        case LDAP_SCOPE_ONELEVEL:
-               rc = monitor_send_children( op, rs, e, 0, &nentries );
+               rc = monitor_send_children( op, rs, e, 0 );
                if ( rc ) {
                        rc = LDAP_OTHER;
                }
@@ -196,10 +190,9 @@ monitor_back_search( Operation *op, SlapReply *rs )
                rc = test_filter( op, e, op->oq_search.rs_filter );
                if ( rc == LDAP_COMPARE_TRUE ) {
                        send_search_entry( op, rs );
-                       nentries++;
                }
 
-               rc = monitor_send_children( op, rs, e, 1, &nentries );
+               rc = monitor_send_children( op, rs, e, 1 );
                if ( rc ) {
                        rc = LDAP_OTHER;
                }
@@ -207,9 +200,8 @@ monitor_back_search( Operation *op, SlapReply *rs )
                break;
        }
        
-       rs->sr_nentries = nentries;
        rs->sr_err = rc;
-       send_search_result( op, rs );
+       send_ldap_result( op, rs );
 
        return( rc == LDAP_SUCCESS ? 0 : 1 );
 }
index 2f3266378ed7b57e676e390d5d21c98092872054..a6f2c9e49b28d8d857e190cd6a6fe8124f500ace 100644 (file)
@@ -33,8 +33,6 @@ passwd_back_search(
        char            *s;
        time_t          stoptime;
 
-       int sent = 0;
-
        LDAPRDN *rdn = NULL;
        struct berval parent = { 0, NULL };
 
@@ -103,7 +101,6 @@ passwd_back_search(
                                rs->sr_entry = e;
                                rs->sr_attrs = op->oq_search.rs_attrs;
                                send_search_entry( op, rs );
-                               sent++;
                        }
                }
 
@@ -147,7 +144,6 @@ passwd_back_search(
                                        rs->sr_entry = e;
                                        rs->sr_attrs = op->oq_search.rs_attrs;
                                        send_search_entry( op, rs );
-                                       sent++;
                                }
 
                                entry_free( e );
@@ -207,7 +203,6 @@ passwd_back_search(
                        rs->sr_entry = e;
                        rs->sr_attrs = op->oq_search.rs_attrs;
                        send_search_entry( op, rs );
-                       sent++;
                }
 
                entry_free( e );
@@ -215,8 +210,7 @@ passwd_back_search(
 
 done:
        if( rs->sr_err != LDAP_NO_SUCH_OBJECT ) rs->sr_matched = NULL;
-       rs->sr_nentries = sent;
-       send_search_result( op, rs );
+       send_ldap_result( op, rs );
 
        if( rdn != NULL ) ldap_rdnfree( rdn );
 
index 9bd791b1753b8d66cf84c266dde7908346ca5874..a5ba374aaaca8f6e563360c9287fc488f092f57f 100644 (file)
@@ -51,9 +51,6 @@ static int glueMode;
 static BackendDB *glueBack;
 
 static slap_response glue_back_response;
-static slap_sresult glue_back_sresult;
-static slap_sendentry glue_back_sendentry;
-static slap_sendreference glue_back_sendreference;
 
 /* Just like select_backend, but only for our backends */
 static BackendDB *
@@ -171,7 +168,6 @@ glue_back_db_destroy (
 
 typedef struct glue_state {
        int err;
-       int nentries;
        int matchlen;
        char *matched;
        int nrefs;
@@ -179,89 +175,65 @@ typedef struct glue_state {
        slap_callback *prevcb;
 } glue_state;
 
-static void
+static int
 glue_back_response ( Operation *op, SlapReply *rs )
 {
        glue_state *gs = op->o_callback->sc_private;
+       slap_callback *tmp = op->o_callback;
 
-       if (rs->sr_err == LDAP_SUCCESS || gs->err != LDAP_SUCCESS)
-               gs->err = rs->sr_err;
-       if (gs->err == LDAP_SUCCESS && gs->matched) {
-               ch_free (gs->matched);
-               gs->matched = NULL;
-               gs->matchlen = 0;
-       }
-       if (gs->err != LDAP_SUCCESS && rs->sr_matched) {
-               int len;
-               len = strlen (rs->sr_matched);
-               if (len > gs->matchlen) {
-                       if (gs->matched)
-                               ch_free (gs->matched);
-                       gs->matched = ch_strdup (rs->sr_matched);
-                       gs->matchlen = len;
+       switch(rs->sr_type) {
+       case REP_SEARCH:
+       case REP_SEARCHREF:
+               op->o_callback = gs->prevcb;
+               if (op->o_callback && op->o_callback->sc_response) {
+                       rs->sr_err = op->o_callback->sc_response( op, rs );
+               } else if (rs->sr_type == REP_SEARCH) {
+                       rs->sr_err = send_search_entry( op, rs );
+               } else {
+                       rs->sr_err = send_search_reference( op, rs );
                }
-       }
-       if (rs->sr_ref) {
-               int i, j, k;
-               BerVarray new;
-
-               for (i=0; rs->sr_ref[i].bv_val; i++);
+               op->o_callback = tmp;
+               return rs->sr_err;
 
-               j = gs->nrefs;
-               if (!j) {
-                       new = ch_malloc ((i+1)*sizeof(struct berval));
-               } else {
-                       new = ch_realloc(gs->refs,
-                               (j+i+1)*sizeof(struct berval));
+       default:
+               if (rs->sr_err == LDAP_SUCCESS || gs->err != LDAP_SUCCESS)
+                       gs->err = rs->sr_err;
+               if (gs->err == LDAP_SUCCESS && gs->matched) {
+                       ch_free (gs->matched);
+                       gs->matched = NULL;
+                       gs->matchlen = 0;
                }
-               for (k=0; k<i; j++,k++) {
-                       ber_dupbv( &new[j], &rs->sr_ref[k] );
+               if (gs->err != LDAP_SUCCESS && rs->sr_matched) {
+                       int len;
+                       len = strlen (rs->sr_matched);
+                       if (len > gs->matchlen) {
+                               if (gs->matched)
+                                       ch_free (gs->matched);
+                               gs->matched = ch_strdup (rs->sr_matched);
+                               gs->matchlen = len;
+                       }
                }
-               new[j].bv_val = NULL;
-               gs->nrefs = j;
-               gs->refs = new;
-       }
-}
-
-static void
-glue_back_sresult ( Operation *op, SlapReply *rs )
-{
-       glue_state *gs = op->o_callback->sc_private;
-
-       gs->nentries += rs->sr_nentries;
-       glue_back_response( op, rs );
-}
+               if (rs->sr_ref) {
+                       int i, j, k;
+                       BerVarray new;
 
-static int
-glue_back_sendentry ( Operation *op, SlapReply *rs )
-{
-       slap_callback *tmp = op->o_callback;
-       glue_state *gs = tmp->sc_private;
-
-       op->o_callback = gs->prevcb;
-       if (op->o_callback && op->o_callback->sc_sendentry) {
-               rs->sr_err = op->o_callback->sc_sendentry(op, rs);
-       } else {
-               rs->sr_err = send_search_entry(op, rs);
-       }
-       op->o_callback = tmp;
-       return rs->sr_err;
-}
-
-static int
-glue_back_sendreference ( Operation *op, SlapReply *rs )
-{
-       slap_callback *tmp = op->o_callback;
-       glue_state *gs = tmp->sc_private;
+                       for (i=0; rs->sr_ref[i].bv_val; i++);
 
-       op->o_callback = gs->prevcb;
-       if (op->o_callback && op->o_callback->sc_sendreference) {
-               rs->sr_err = op->o_callback->sc_sendreference( op, rs );
-       } else {
-               rs->sr_err = send_search_reference( op, rs );
+                       j = gs->nrefs;
+                       if (!j) {
+                               new = ch_malloc ((i+1)*sizeof(struct berval));
+                       } else {
+                               new = ch_realloc(gs->refs,
+                                       (j+i+1)*sizeof(struct berval));
+                       }
+                       for (k=0; k<i; j++,k++) {
+                               ber_dupbv( &new[j], &rs->sr_ref[k] );
+                       }
+                       new[j].bv_val = NULL;
+                       gs->nrefs = j;
+                       gs->refs = new;
+               }
        }
-       op->o_callback = tmp;
-       return rs->sr_err;
 }
 
 static int
@@ -271,15 +243,11 @@ glue_back_search ( Operation *op, SlapReply *rs )
        glueinfo *gi = (glueinfo *) b0->bd_info;
        int i;
        long stoptime = 0;
-       glue_state gs = {0, 0, 0, NULL, 0, NULL, NULL};
-       slap_callback cb;
+       glue_state gs = {0, 0, NULL, 0, NULL, NULL};
+       slap_callback cb = { glue_back_response };
        int scope0, slimit0, tlimit0;
        struct berval dn, ndn;
 
-       cb.sc_response = glue_back_response;
-       cb.sc_sresult = glue_back_sresult;
-       cb.sc_sendentry = glue_back_sendentry;
-       cb.sc_sendreference = glue_back_sendreference;
        cb.sc_private = &gs;
 
        gs.prevcb = op->o_callback;
@@ -324,7 +292,7 @@ glue_back_search ( Operation *op, SlapReply *rs )
                                }
                        }
                        if (slimit0) {
-                               op->ors_slimit = slimit0 - gs.nentries;
+                               op->ors_slimit = slimit0 - rs->sr_nentries;
                                if (op->ors_slimit <= 0) {
                                        rs->sr_err = gs.err = LDAP_SIZELIMIT_EXCEEDED;
                                        break;
@@ -383,9 +351,8 @@ end_of_loop:;
        rs->sr_err = gs.err;
        rs->sr_matched = gs.matched;
        rs->sr_ref = gs.refs;
-       rs->sr_nentries = gs.nentries;
 
-       send_search_result( op, rs );
+       send_ldap_result( op, rs );
 
 done:
        op->o_bd = b0;
index 96c45a2ba8572e63a123097ad2d2341714b4ac20..3fa6a89b1db52a0ce00bfc3f8b8915d648ced0e1 100644 (file)
@@ -408,7 +408,6 @@ long connection_init(
        if( c->c_struct_state == SLAP_C_UNINITIALIZED ) {
                c->c_send_ldap_result = slap_send_ldap_result;
                c->c_send_search_entry = slap_send_search_entry;
-               c->c_send_search_result = slap_send_search_result;
                c->c_send_search_reference = slap_send_search_reference;
                c->c_send_ldap_extended = slap_send_ldap_extended;
 #ifdef LDAP_RES_INTERMEDIATE_RESP
index 13837bdb00c28c539821d7c8088fd82f0b3fed1d..07b1fde1dad0f30d9e3368793f1db4da18be3fb3 100644 (file)
@@ -888,9 +888,6 @@ LDAP_SLAPD_F (int) slap_sasl_authorized LDAP_P((
 LDAP_SLAPD_F (int) slap_sasl_regexp_config LDAP_P((
        const char *match, const char *replace ));
 LDAP_SLAPD_F (int) slap_sasl_setpolicy LDAP_P(( const char * ));
-LDAP_SLAPD_F (slap_response) slap_cb_null_response;
-LDAP_SLAPD_F (slap_sresult) slap_cb_null_sresult;
-LDAP_SLAPD_F (slap_sendreference) slap_cb_null_sreference;
 
 
 /*
index adaf3c0ab33f49740484c3dff0d2cdf93eee43dd..438b869b49e1f0724f90a205f16a295cc78d3d0a 100644 (file)
@@ -483,7 +483,7 @@ slap_send_ldap_result( Operation *op, SlapReply *rs )
 
        send_ldap_response( op, rs );
 
-       if ( rs->sr_type == REP_SRESULT ) {
+       if ( op->o_tag == LDAP_REQ_SEARCH ) {
                char nbuf[64];
                snprintf( nbuf, sizeof nbuf, "%d nentries=%d", rs->sr_err, rs->sr_nentries );
 
@@ -569,13 +569,6 @@ slap_send_ldap_intermediate_resp( Operation *op, SlapReply *rs )
 }
 #endif
 
-void
-slap_send_search_result( Operation *op, SlapReply *rs )
-{
-       rs->sr_type = REP_SRESULT;
-       slap_send_ldap_result( op, rs );
-}
-
 int
 slap_send_search_entry( Operation *op, SlapReply *rs )
 {
@@ -602,8 +595,8 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
        char **e_flags = NULL;
 
        rs->sr_type = REP_SEARCH;
-       if (op->o_callback && op->o_callback->sc_sendentry) {
-               return op->o_callback->sc_sendentry( op, rs );
+       if (op->o_callback && op->o_callback->sc_response) {
+               return op->o_callback->sc_response( op, rs );
        }
 
 #ifdef NEW_LOGGING
@@ -1143,6 +1136,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
 
                return -1;
        }
+       rs->sr_nentries++;
 
        ldap_pvt_thread_mutex_lock( &num_sent_mutex );
        num_bytes_sent += bytes;
@@ -1183,8 +1177,8 @@ slap_send_search_reference( Operation *op, SlapReply *rs )
        AttributeDescription *ad_entry = slap_schema.si_ad_entry;
 
        rs->sr_type = REP_SEARCHREF;
-       if (op->o_callback && op->o_callback->sc_sendreference) {
-               return op->o_callback->sc_sendreference( op, rs );
+       if (op->o_callback && op->o_callback->sc_response) {
+               return op->o_callback->sc_response( op, rs );
        }
 
 #ifdef NEW_LOGGING
index 5c840cfcc98d25732d4d797eb6cc93c0b699fef6..d6fc24721ac7814080d82034f6b99085fcf2c7f5 100644 (file)
@@ -305,7 +305,7 @@ typedef struct lookup_info {
        sasl_server_params_t *sparams;
 } lookup_info;
 
-static slap_sendentry sasl_ap_lookup, sasl_cb_checkpass;
+static slap_response sasl_ap_lookup, sasl_cb_checkpass;
 
 static int
 sasl_ap_lookup( Operation *op, SlapReply *rs )
@@ -318,6 +318,8 @@ sasl_ap_lookup( Operation *op, SlapReply *rs )
        slap_callback *tmp = op->o_callback;
        lookup_info *sl = tmp->sc_private;
 
+       if (rs->sr_type != REP_SEARCH) return 0;
+
        for( i = 0; i < sl->last; i++ ) {
                const char *name = sl->list[i].name;
 
@@ -420,8 +422,7 @@ slap_auxprop_lookup(
        }
 
        if (doit) {
-               slap_callback cb = { slap_cb_null_response,
-                       slap_cb_null_sresult, sasl_ap_lookup, slap_cb_null_sreference, NULL };
+               slap_callback cb = { sasl_ap_lookup };
 
                cb.sc_private = &sl;
 
@@ -489,6 +490,8 @@ sasl_cb_checkpass( Operation *op, SlapReply *rs )
        Attribute *a;
        struct berval *bv;
        
+       if (rs->sr_type != REP_SEARCH) return 0;
+
        ci->rc = SASL_NOVERIFY;
 
        a = attr_find( rs->sr_entry->e_attrs, slap_schema.si_ad_userPassword );
@@ -543,8 +546,7 @@ slap_sasl_checkpass(
 
        op.o_bd = select_backend( &op.o_req_ndn, 0, 1 );
        if ( op.o_bd && op.o_bd->be_search ) {
-               slap_callback cb = { slap_cb_null_response,
-                       slap_cb_null_sresult, sasl_cb_checkpass, slap_cb_null_sreference, NULL };
+               slap_callback cb = { sasl_cb_checkpass };
                SlapReply rs = {REP_RESULT};
 
                ci.cred.bv_val = (char *)pass;
index dd288d8429c0458a603aafc78e2fc53740998a2d..80ec85de2386654fb2c01ca6fb68627824e8d64e 100644 (file)
@@ -327,25 +327,13 @@ static int slap_sasl_regexp( struct berval *in, struct berval *out )
        return( 1 );
 }
 
-/* Two empty callback functions to avoid sending results */
-void slap_cb_null_response( Operation *o, SlapReply *rs )
-{
-}
-
-void slap_cb_null_sresult( Operation *o, SlapReply *rs )
-{
-}
-
-int slap_cb_null_sreference( Operation *o, SlapReply *rs )
-{
-       return 0;
-}
-
 /* This callback actually does some work...*/
 static int sasl_sc_sasl2dn( Operation *o, SlapReply *rs )
 {
        struct berval *ndn = o->o_callback->sc_private;
 
+       if (rs->sr_type != REP_SEARCH) return 0;
+
        /* We only want to be called once */
        if( ndn->bv_val ) {
                free(ndn->bv_val);
@@ -375,6 +363,8 @@ static int sasl_sc_smatch( Operation *o, SlapReply *rs )
 {
        smatch_info *sm = o->o_callback->sc_private;
 
+       if (rs->sr_type != REP_SEARCH) return 0;
+
        if (dn_match(sm->dn, &rs->sr_entry->e_nname)) {
                sm->match = 1;
                return -1;      /* short-circuit the search */
@@ -398,12 +388,7 @@ int slap_sasl_match(Connection *conn, struct berval *rule, struct berval *assert
        int rc; 
        regex_t reg;
        smatch_info sm;
-       slap_callback cb = {
-               slap_cb_null_response,
-               slap_cb_null_sresult,
-               sasl_sc_smatch,
-               slap_cb_null_sreference
-       };
+       slap_callback cb = { sasl_sc_smatch };
        Operation op = {0};
        SlapReply rs = {REP_RESULT};
 
@@ -560,8 +545,7 @@ void slap_sasl2dn( Connection *conn,
        struct berval *saslname, struct berval *sasldn )
 {
        int rc;
-       slap_callback cb = { slap_cb_null_response,
-               slap_cb_null_sresult, sasl_sc_sasl2dn, slap_cb_null_sreference, NULL};
+       slap_callback cb = { sasl_sc_sasl2dn };
        Operation op = {0};
        SlapReply rs = {REP_RESULT};
        struct berval regout = { 0, NULL };
index e70cb0029ec2c54803294c85519615ed17ad2b98..1b85eb0e657a6e874bafb5dda63a107e5cde3502 100644 (file)
@@ -309,8 +309,7 @@ do_search(
                        entry_free( entry );
 
                        rs->sr_err = LDAP_SUCCESS;
-                       rs->sr_nentries = 1;
-                       send_search_result( op, rs );
+                       send_ldap_result( op, rs );
 #ifdef LDAP_SLAPI
                        doPostSearchPluginFNs( op );
 #endif /* LDAP_SLAPI */
index ea137bcc3a395a4a483ce2a694312a57e90ac99f..07ef0d28ccc8bc7e4177072b6e61c7fbf34f1b96 100644 (file)
@@ -39,6 +39,7 @@
 #define SLAP_NVALUES 1
 /* #define SLAP_NVALUES_ON_DISK 1 */
 #define SLAP_EXTENDED_SCHEMA 1
+#define LDAP_CACHING
 #endif
 
 LDAP_BEGIN_DECL
@@ -1487,7 +1488,6 @@ typedef struct req_extended_s {
 typedef enum slap_reply_e {
        REP_RESULT,
        REP_SASL,
-       REP_SRESULT,
        REP_EXTENDED,
        REP_SEARCH,
        REP_SEARCHREF
@@ -1497,18 +1497,15 @@ typedef struct rep_sasl_s {
        struct berval *r_sasldata;
 } rep_sasl_s;
 
-typedef struct rep_sresult_s {
-       int r_nentries;
-} rep_sresult_s;
-
 typedef struct rep_extended_s {
        const char *r_rspoid;
        struct berval *r_rspdata;
 } rep_extended_s;
 
 typedef struct rep_search_s {
-       AttributeName *r_attrs;
        Entry *r_entry;
+       AttributeName *r_attrs;
+       int r_nentries;
        BerVarray r_v2ref;
 } rep_search_s;
 
@@ -1523,7 +1520,6 @@ typedef struct slap_rep {
        LDAPControl **sr_ctrls;
        union sr_u {
                rep_sasl_s sru_sasl;
-               rep_sresult_s sru_sresult;
                rep_extended_s sru_extended;
                rep_search_s sru_search;
        } sr_un;
@@ -1533,10 +1529,10 @@ typedef struct slap_rep {
 #define        sr_attrs sr_un.sru_search.r_attrs
 #define        sr_entry sr_un.sru_search.r_entry
 #define        sr_v2ref sr_un.sru_search.r_v2ref
+#define        sr_nentries sr_un.sru_search.r_nentries
 #define        sr_rspoid sr_un.sru_extended.r_rspoid
 #define        sr_rspdata sr_un.sru_extended.r_rspdata
 #define        sr_sasldata sr_un.sru_sasl.r_sasldata
-#define        sr_nentries sr_un.sru_sresult.r_nentries
 
 typedef int (BI_op_bind) LDAP_P(( struct slap_op *op, struct slap_rep *rs ));
 typedef int (BI_op_unbind) LDAP_P(( struct slap_op *op, struct slap_rep *rs ));
@@ -1690,16 +1686,10 @@ struct slap_backend_info {
 #define o_tls_ssf              o_authz.sai_tls_ssf
 #define o_sasl_ssf             o_authz.sai_sasl_ssf
 
-typedef void (slap_response)( struct slap_op *, struct slap_rep * );
-typedef void (slap_sresult)( struct slap_op *, struct slap_rep * );
-typedef int (slap_sendentry)( struct slap_op *, struct slap_rep * );
-typedef int (slap_sendreference)( struct slap_op *, struct slap_rep * );
+typedef int (slap_response)( struct slap_op *, struct slap_rep * );
 
 typedef struct slap_callback {
        slap_response *sc_response;
-       slap_sresult *sc_sresult;
-       slap_sendentry *sc_sendentry;
-       slap_sendreference *sc_sendreference;
        void *sc_private;
 } slap_callback;
 
@@ -1908,7 +1898,6 @@ do { (rs)->sr_err = err; (rs)->sr_text = text; \
 send_ldap_disconnect( op, rs ); } while (0)
 typedef void (SEND_LDAP_RESULT)(struct slap_op *op, struct slap_rep *rs);
 typedef int (SEND_SEARCH_ENTRY)(struct slap_op *op, struct slap_rep *rs);
-typedef void (SEND_SEARCH_RESULT)(struct slap_op *op, struct slap_rep *rs);
 typedef int (SEND_SEARCH_REFERENCE)(struct slap_op *op, struct slap_rep *rs);
 typedef void (SEND_LDAP_EXTENDED)(struct slap_op *op, struct slap_rep *rs);
 typedef void (SEND_LDAP_INTERMEDIATE_RESP)(struct slap_op *op, struct slap_rep *rs);
@@ -1916,8 +1905,6 @@ typedef void (SEND_LDAP_INTERMEDIATE_RESP)(struct slap_op *op, struct slap_rep *
 (op->o_conn->c_send_ldap_result)( op, rs )
 #define send_search_entry( op, rs ) \
 (op->o_conn->c_send_search_entry)( op, rs )
-#define send_search_result( op, rs ) \
-(op->o_conn->c_send_search_result)( op, rs )
 #define send_search_reference( op, rs ) \
 (op->o_conn->c_send_search_reference)( op, rs )
 #define send_ldap_extended( op, rs ) \
@@ -2015,7 +2002,6 @@ typedef struct slap_conn {
         */
        SEND_LDAP_RESULT *c_send_ldap_result;
        SEND_SEARCH_ENTRY *c_send_search_entry;
-       SEND_SEARCH_RESULT *c_send_search_result;
        SEND_SEARCH_REFERENCE *c_send_search_reference;
        SEND_LDAP_EXTENDED *c_send_ldap_extended;
 #ifdef LDAP_RES_INTERMEDIATE_RESP
index ade485e952de7cb6d3d4b3e2d4012e83535c3265..88f58c441b6e88c469c1e22c40e3990b56d00cce 100644 (file)
@@ -9,7 +9,7 @@
 
 
 LIBRARY = libslapi.la
-XLIBRARY = libtmpslapd.a
+#XLIBRARY = libtmpslapd.a
 
 #all-common: $(LIBRARY) $(PROGRAMS)
 #      @touch plugin.c slapi_pblock.c slapi_utils.c slapi_ops.c
@@ -36,7 +36,7 @@ NT_LINK_LIBS = $(AC_LIBS)
 XINCPATH = -I.. -I$(srcdir)/..
 XDEFS = $(MODULES_CPPFLAGS)
 
-UNIX_LINK_LIBS = ./libtmpslapd.a ../libbackends.a ../../../libraries/libavl/libavl.a ../../../libraries/liblber/.libs/liblber.a ../../../libraries/libldbm/libldbm.a ../../../libraries/libldif/libldif.a ../../../libraries/liblutil/liblutil.a ../../../libraries/liblunicode/liblunicode.a ../../../libraries/libldap_r/.libs/libldap_r.a ./libtmpslapd.a
+#UNIX_LINK_LIBS = ./libtmpslapd.a ../libbackends.a ../../../libraries/libavl/libavl.a ../../../libraries/liblber/.libs/liblber.a ../../../libraries/libldbm/libldbm.a ../../../libraries/libldif/libldif.a ../../../libraries/liblutil/liblutil.a ../../../libraries/liblunicode/liblunicode.a ../../../libraries/libldap_r/.libs/libldap_r.a ./libtmpslapd.a
 
 BUILD_MOD = @BUILD_SLAPI@
 
index a2461ec9f204582778b1d46f958cd6db23f681a7..1d235c4f5c28560ddd909a3401e290aa22f37818 100644 (file)
@@ -38,6 +38,10 @@ internal_result_v3(
        Operation       *op, 
        SlapReply       *rs )
 {
+       if (op->o_tag == LDAP_REQ_SEARCH)
+               slapi_pblock_set( (Slapi_PBlock *)op->o_pb,
+                       SLAPI_NENTRIES, (void *)sr->sr_nentries );
+
        return;
 }
 
@@ -93,17 +97,6 @@ internal_search_entry(
        return LDAP_SUCCESS;
 }
 
-static void
-internal_search_result(
-       Operation       *op,
-       SlapReply       *sr )
-{
-       slapi_pblock_set( (Slapi_PBlock *)op->o_pb,
-                       SLAPI_NENTRIES, (void *)sr->sr_nentries );
-
-       return;
-}
-
 static void
 internal_result_ext(
        Operation       *op,    
@@ -217,7 +210,6 @@ slapiConnectionInit(
 
        pConn->c_send_ldap_result = internal_result_v3;
        pConn->c_send_search_entry = internal_search_entry;
-       pConn->c_send_search_result = internal_search_result;
        pConn->c_send_ldap_extended = internal_result_ext;
        pConn->c_send_search_reference = internal_search_reference;
 
index cd74cbb6725f9e194427f4f17d19e823bdb6e4ed..47c6aca9390a41e15e73bdb94113577e3f6868ba 100644 (file)
@@ -1363,6 +1363,8 @@ slapi_send_ldap_result(
        rs.sr_ref = NULL;
        rs.sr_ctrls = NULL;
 
+       slapi_pblock_get( pb, SLAPI_RESCONTROLS, &rs.sr_ctrls );
+
        if ( err == LDAP_SASL_BIND_IN_PROGRESS ) {
                slapi_pblock_get( pb, SLAPI_BIND_RET_SASLCREDS, (void *) &rs.sr_sasldata );
                send_ldap_sasl( op, &rs );
@@ -1377,8 +1379,8 @@ slapi_send_ldap_result(
                return;
        }
 
-       rs.sr_type = REP_RESULT;
-       slapi_pblock_get( pb, SLAPI_RESCONTROLS, &rs.sr_ctrls );
+       if (op->o_tag == LDAP_REQ_SEARCH)
+               rs.sr_nentries = nentries;
 
        send_ldap_result( op, &rs );
 #endif /* LDAP_SLAPI */
index f5c1ca89723cca10d4a19028f7f4c906ab899423..5d40a5bdafe34a1d8362dca5fef9eb32faae48da 100644 (file)
@@ -64,12 +64,6 @@ slap_send_ldap_result( Operation *op, SlapReply *rs )
        assert(0);
 }
 
-void
-slap_send_search_result( Operation *op, SlapReply *rs )
-{
-       assert(0);
-}
-
 int
 slap_send_search_entry( Operation *op, SlapReply *rs )
 {