From a317f01dc1c77ac706c3044475db9b375b940e29 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Wed, 16 Jun 2004 15:26:21 +0000 Subject: [PATCH] improve pagedResults ignoring (hopefully) --- servers/slapd/back-bdb/search.c | 6 +++--- servers/slapd/controls.c | 21 ++++++++++++++++++--- servers/slapd/limits.c | 2 +- servers/slapd/slap.h | 1 + 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/servers/slapd/back-bdb/search.c b/servers/slapd/back-bdb/search.c index 3d20894bde..2737d1fb82 100644 --- a/servers/slapd/back-bdb/search.c +++ b/servers/slapd/back-bdb/search.c @@ -754,7 +754,7 @@ dn2entry_retry: tentries = BDB_IDL_N(candidates); } - if ( get_pagedresults(sop) ) { + if ( get_pagedresults(sop) > SLAP_NO_CONTROL ) { if ( (ID)( sop->o_pagedresults_state.ps_cookie ) == 0 ) { id = bdb_idl_first( candidates, &cursor ); @@ -1133,7 +1133,7 @@ id2entry_retry: goto done; } - if ( get_pagedresults(sop) ) { + if ( get_pagedresults(sop) > SLAP_NO_CONTROL ) { if ( rs->sr_nentries >= sop->o_pagedresults_size ) { send_paged_response( sop, rs, &lastid, tentries ); goto done; @@ -1456,7 +1456,7 @@ nochange: rs->sr_ref = rs->sr_v2ref; rs->sr_err = (rs->sr_v2ref == NULL) ? LDAP_SUCCESS : LDAP_REFERRAL; rs->sr_rspoid = NULL; - if ( get_pagedresults(sop) ) { + if ( get_pagedresults(sop) > SLAP_NO_CONTROL ) { send_paged_response( sop, rs, NULL, 0 ); } else { send_ldap_result( sop, rs ); diff --git a/servers/slapd/controls.c b/servers/slapd/controls.c index c010122a91..db981a9a8c 100644 --- a/servers/slapd/controls.c +++ b/servers/slapd/controls.c @@ -918,9 +918,24 @@ static int parsePagedResults ( op->o_pagedresults_size = size; - op->o_pagedresults = ctrl->ldctl_iscritical - ? SLAP_CRITICAL_CONTROL - : SLAP_NONCRITICAL_CONTROL; + /* NOTE: according to RFC 2696 3.: + + If the page size is greater than or equal to the sizeLimit value, the + server should ignore the control as the request can be satisfied in a + single page. + + * NOTE: this assumes that the op->ors_slimit be set + * before the controls are parsed. + */ + if ( op->ors_slimit > 0 && size >= op->ors_slimit ) { + op->o_pagedresults = SLAP_IGNORED_CONTROL; + + } else if ( ctrl->ldctl_iscritical ) { + op->o_pagedresults = SLAP_CRITICAL_CONTROL; + + } else { + op->o_pagedresults = SLAP_NONCRITICAL_CONTROL; + } return LDAP_SUCCESS; } diff --git a/servers/slapd/limits.c b/servers/slapd/limits.c index 836b4624b5..b32ea0be77 100644 --- a/servers/slapd/limits.c +++ b/servers/slapd/limits.c @@ -1048,7 +1048,7 @@ limits_check( Operation *op, SlapReply *rs ) } /* if paged results is requested */ - if ( get_pagedresults( op ) ) { + if ( get_pagedresults( op ) > SLAP_NO_CONTROL ) { int slimit = -2; int pr_total; diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 7c7f33b463..293c3cb79c 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -2072,6 +2072,7 @@ typedef struct slap_op { char o_do_not_cache; /* don't cache groups from this op */ char o_is_auth_check; /* authorization in progress */ +#define SLAP_IGNORED_CONTROL -1 #define SLAP_NO_CONTROL 0 #define SLAP_NONCRITICAL_CONTROL 1 #define SLAP_CRITICAL_CONTROL 2 -- 2.39.5