honor size limits when using paged results

This commit is contained in:
Pierangelo Masarati 2004-04-09 11:44:28 +00:00
parent 0505c64f08
commit fadf3398d4
3 changed files with 30 additions and 10 deletions

View File

@ -385,7 +385,6 @@ bdb_do_search( Operation *op, SlapReply *rs, Operation *sop,
Filter contextcsnand, contextcsnle, cookief, csnfnot,
csnfeq, csnfand, csnfge;
AttributeAssertion aa_ge, aa_eq, aa_le;
int entry_count = 0;
struct berval *search_context_csn = NULL;
DB_LOCK ctxcsn_lock;
LDAPControl *ctrls[SLAP_MAX_RESPONSE_CONTROLS];
@ -755,6 +754,7 @@ dn2entry_retry:
if ( get_pagedresults(sop) ) {
if ( sop->o_pagedresults_state.ps_cookie == 0 ) {
id = 0;
} else {
if ( sop->o_pagedresults_size == 0 ) {
rs->sr_err = LDAP_SUCCESS;
@ -1121,6 +1121,21 @@ id2entry_retry:
}
if ( get_pagedresults(sop) ) {
if ( sop->ors_limit /* isroot == TRUE */
&& sop->ors_slimit < sop->o_pagedresults_state.ps_count ) {
if (!IS_PSEARCH) {
bdb_cache_return_entry_r( bdb->bi_dbenv,
&bdb->bi_cache, e, &lock );
}
e = NULL;
rs->sr_entry = NULL;
rs->sr_err = LDAP_SIZELIMIT_EXCEEDED;
rs->sr_ref = rs->sr_v2ref;
send_ldap_result( sop, rs );
rs->sr_err = LDAP_SUCCESS;
goto done;
}
if ( rs->sr_nentries >= sop->o_pagedresults_size ) {
send_pagerequest_response( sop, rs,
lastid, tentries );
@ -1700,6 +1715,7 @@ send_pagerequest_response(
respcookie = ( PagedResultsCookie )lastid;
op->o_conn->c_pagedresults_state.ps_cookie = respcookie;
op->o_conn->c_pagedresults_state.ps_count = op->o_pagedresults_state.ps_count + rs->sr_nentries;
cookie.bv_len = sizeof( respcookie );
cookie.bv_val = (char *)&respcookie;
@ -1723,3 +1739,4 @@ send_pagerequest_response(
done:
(void) ber_free_buf( ber );
}

View File

@ -898,10 +898,12 @@ static int parsePagedResults (
rs->sr_text = "paged results cookie is invalid or old";
return LDAP_UNWILLING_TO_PERFORM;
}
} else {
/* Initial request. Initialize state. */
op->o_pagedresults_state.ps_cookie = 0;
op->o_pagedresults_state.ps_id = NOID;
op->o_pagedresults_state.ps_count = 0;
}
op->o_pagedresults_size = size;

View File

@ -1889,6 +1889,7 @@ typedef struct slap_paged_state {
Backend *ps_be;
PagedResultsCookie ps_cookie;
ID ps_id;
unsigned long ps_count;
} PagedResultsState;
#define LDAP_PSEARCH_BY_ADD 0x01