clarify no limits in (internal) searches

This commit is contained in:
Pierangelo Masarati 2004-06-12 11:33:21 +00:00
parent ada1ee11fe
commit d1b692ceb4
14 changed files with 47 additions and 32 deletions

View File

@ -881,7 +881,9 @@ loop_begin:
}
/* check time limit */
if ( sop->ors_tlimit != -1 && slap_get_time() > stoptime ) {
if ( sop->ors_tlimit != SLAP_NO_LIMIT
&& slap_get_time() > stoptime )
{
rs->sr_err = LDAP_TIMELIMIT_EXCEEDED;
rs->sr_ref = rs->sr_v2ref;
send_ldap_result( sop, rs );

View File

@ -77,7 +77,7 @@ ldap_back_search(
/* should we check return values? */
if (op->ors_deref != -1)
ldap_set_option( lc->ld, LDAP_OPT_DEREF, (void *)&op->ors_deref);
if (op->ors_tlimit != -1) {
if (op->ors_tlimit != SLAP_NO_LIMIT) {
tv.tv_sec = op->ors_tlimit;
tv.tv_usec = 0;
} else {

View File

@ -231,7 +231,9 @@ searchit:
}
/* check time limit */
if ( op->ors_tlimit != -1 && slap_get_time() > stoptime ) {
if ( op->ors_tlimit != SLAP_NO_LIMIT
&& slap_get_time() > stoptime )
{
rs->sr_err = LDAP_TIMELIMIT_EXCEEDED;
send_ldap_result( op, rs );
rc = LDAP_SUCCESS;

View File

@ -69,11 +69,9 @@ passwd_back_search(
AttributeDescription *ad_objectClass = slap_schema.si_ad_objectClass;
op->ors_tlimit = (op->ors_tlimit > op->o_bd->be_timelimit || op->ors_tlimit < 1) ? op->o_bd->be_timelimit
: op->ors_tlimit;
stoptime = op->o_time + op->ors_tlimit;
op->ors_slimit = (op->ors_slimit > op->o_bd->be_sizelimit || op->ors_slimit < 1) ? op->o_bd->be_sizelimit
: op->ors_slimit;
if (op->ors_tlimit != SLAP_NO_LIMIT ) {
stoptime = op->o_time + op->ors_tlimit;
}
/* Handle a query for the base of this backend */
if ( be_issuffix( op->o_bd, &op->o_req_ndn ) ) {
@ -150,7 +148,9 @@ passwd_back_search(
}
/* check time limit */
if ( slap_get_time() > stoptime ) {
if ( op->ors_tlimit != SLAP_NO_LIMIT
&& slap_get_time() > stoptime )
{
send_ldap_error( op, rs, LDAP_TIMELIMIT_EXCEEDED, NULL );
endpwent();
ldap_pvt_thread_mutex_unlock( &passwd_mutex );

View File

@ -1459,7 +1459,9 @@ backsql_search( Operation *op, SlapReply *rs )
}
/* check time limit */
if ( op->ors_tlimit != -1 && slap_get_time() > stoptime ) {
if ( op->ors_tlimit != SLAP_NO_LIMIT
&& slap_get_time() > stoptime )
{
rs->sr_err = LDAP_TIMELIMIT_EXCEEDED;
rs->sr_ctrls = NULL;
rs->sr_ref = rs->sr_v2ref;
@ -1601,8 +1603,9 @@ backsql_search( Operation *op, SlapReply *rs )
}
entry_free( entry );
if ( op->ors_slimit != -1
&& rs->sr_nentries >= op->ors_slimit ) {
if ( op->ors_slimit != SLAP_NO_LIMIT
&& rs->sr_nentries >= op->ors_slimit )
{
rs->sr_err = LDAP_SIZELIMIT_EXCEEDED;
send_ldap_result( op, rs );
goto end_of_search;

View File

@ -194,7 +194,9 @@ glue_back_response ( Operation *op, SlapReply *rs )
switch(rs->sr_type) {
case REP_SEARCH:
if ( gs->slimit != -1 && rs->sr_nentries >= gs->slimit ) {
if ( gs->slimit != SLAP_NO_LIMIT
&& rs->sr_nentries >= gs->slimit )
{
rs->sr_err = gs->err = LDAP_SIZELIMIT_EXCEEDED;
return -1;
}
@ -313,14 +315,14 @@ glue_back_search ( Operation *op, SlapReply *rs )
continue;
if (!dnIsSuffix(&gi->n[i].be->be_nsuffix[0], &b1->be_nsuffix[0]))
continue;
if (tlimit0 != -1) {
if (tlimit0 != SLAP_NO_LIMIT) {
op->ors_tlimit = stoptime - slap_get_time ();
if (op->ors_tlimit <= 0) {
rs->sr_err = gs.err = LDAP_TIMELIMIT_EXCEEDED;
break;
}
}
if (slimit0 != -1) {
if (slimit0 != SLAP_NO_LIMIT) {
op->ors_slimit = slimit0 - rs->sr_nentries;
if (op->ors_slimit < 0) {
rs->sr_err = gs.err = LDAP_SIZELIMIT_EXCEEDED;

View File

@ -1001,11 +1001,11 @@ limits_check( Operation *op, SlapReply *rs )
op->ors_limit = NULL;
if ( op->ors_tlimit == 0 ) {
op->ors_tlimit = -1;
op->ors_tlimit = SLAP_NO_LIMIT;
}
if ( op->ors_slimit == 0 ) {
op->ors_slimit = -1;
op->ors_slimit = SLAP_NO_LIMIT;
}
/* if not root, get appropriate limits */
@ -1084,7 +1084,7 @@ limits_check( Operation *op, SlapReply *rs )
if ( pr_total == -1 ) {
slimit = -1;
} else if ( pr_total > 0 && ( op->ors_slimit == -1 || op->ors_slimit > pr_total ) ) {
} else if ( pr_total > 0 && ( op->ors_slimit == SLAP_NO_LIMIT || op->ors_slimit > pr_total ) ) {
rs->sr_err = LDAP_ADMINLIMIT_EXCEEDED;
send_ldap_result( op, rs );
rs->sr_err = LDAP_SUCCESS;

View File

@ -869,8 +869,8 @@ remove_query_data (
op->o_req_ndn = op->o_bd->be_nsuffix[0];
op->ors_scope = LDAP_SCOPE_SUBTREE;
op->ors_deref = LDAP_DEREF_NEVER;
op->ors_slimit = -1;
op->ors_tlimit = -1;
op->ors_slimit = SLAP_NO_LIMIT;
op->ors_tlimit = SLAP_NO_LIMIT;
op->ors_filter = &filter;
op->ors_filterstr.bv_val = filter_str;
op->ors_filterstr.bv_len = strlen(filter_str);

View File

@ -551,8 +551,8 @@ refint_response(
nop.o_tag = LDAP_REQ_SEARCH;
nop.ors_scope = LDAP_SCOPE_SUBTREE;
nop.ors_deref = LDAP_DEREF_NEVER;
nop.ors_slimit = -1;
nop.ors_tlimit = -1;
nop.ors_slimit = SLAP_NO_LIMIT;
nop.ors_tlimit = SLAP_NO_LIMIT;
nop.o_req_ndn = id->dn;
nop.o_req_dn = id->dn;

View File

@ -349,8 +349,8 @@ static int unique_add(
nop.o_tag = LDAP_REQ_SEARCH;
nop.ors_scope = LDAP_SCOPE_SUBTREE;
nop.ors_deref = LDAP_DEREF_NEVER;
nop.ors_slimit = -1;
nop.ors_tlimit = -1;
nop.ors_slimit = SLAP_NO_LIMIT;
nop.ors_tlimit = SLAP_NO_LIMIT;
nop.o_req_ndn = ud->dn;
nop.o_ndn = op->o_bd->be_rootndn;
@ -482,8 +482,8 @@ static int unique_modify(
nop.o_tag = LDAP_REQ_SEARCH;
nop.ors_scope = LDAP_SCOPE_SUBTREE;
nop.ors_deref = LDAP_DEREF_NEVER;
nop.ors_slimit = -1;
nop.ors_tlimit = -1;
nop.ors_slimit = SLAP_NO_LIMIT;
nop.ors_tlimit = SLAP_NO_LIMIT;
nop.o_req_ndn = ud->dn;
nop.o_ndn = op->o_bd->be_rootndn;
@ -612,8 +612,8 @@ static int unique_modrdn(
nop.o_tag = LDAP_REQ_SEARCH;
nop.ors_scope = LDAP_SCOPE_SUBTREE;
nop.ors_deref = LDAP_DEREF_NEVER;
nop.ors_slimit = -1;
nop.ors_tlimit = -1;
nop.ors_slimit = SLAP_NO_LIMIT;
nop.ors_tlimit = SLAP_NO_LIMIT;
nop.o_req_ndn = ud->dn;
nop.o_ndn = op->o_bd->be_rootndn;

View File

@ -482,6 +482,7 @@ slap_auxprop_lookup(
op.o_req_dn = op.o_req_ndn;
op.ors_scope = LDAP_SCOPE_BASE;
op.ors_deref = LDAP_DEREF_NEVER;
op.ors_tlimit = SLAP_NO_LIMIT;
op.ors_slimit = 1;
op.ors_filter = &generic_filter;
op.ors_filterstr = generic_filterstr;

View File

@ -1049,7 +1049,7 @@ exact_match:
if( !BER_BVISNULL( &op.o_req_dn ) ) ch_free( op.o_req_dn.bv_val );
ber_dupbv_x( &op.o_req_dn, &op.o_req_ndn, op.o_tmpmemctx );
op.oq_search.rs_slimit = 1;
op.oq_search.rs_tlimit = -1;
op.oq_search.rs_tlimit = SLAP_NO_LIMIT;
op.o_sync_slog_size = -1;
op.o_bd->be_search( &op, &rs );
@ -1234,7 +1234,7 @@ void slap_sasl2dn( Operation *opx,
#endif
op.oq_search.rs_deref = LDAP_DEREF_NEVER;
op.oq_search.rs_slimit = 1;
op.oq_search.rs_tlimit = -1;
op.oq_search.rs_tlimit = SLAP_NO_LIMIT;
op.oq_search.rs_attrsonly = 1;
/* use req_ndn as req_dn instead of non-pretty base of uri */
if( !BER_BVISNULL( &op.o_req_dn ) ) ch_free( op.o_req_dn.bv_val );

View File

@ -1312,6 +1312,9 @@ struct slap_limits_set {
int lms_s_pr_total;
};
/* Note: this is different from LDAP_NO_LIMIT (0); slapd internal use only */
#define SLAP_NO_LIMIT -1
struct slap_limits {
unsigned lm_flags; /* type of pattern */
#define SLAP_LIMITS_UNDEFINED 0x0000U
@ -1509,6 +1512,8 @@ struct slap_backend_db {
#define SLAP_RESTRICT_OP_SEARCH 0x0080U
#define SLAP_RESTRICT_OP_MASK 0x00FFU
#define SLAP_RESTRICT_READONLY 0x80000000U
#define SLAP_RESTRICT_EXOP_START_TLS 0x0100U
#define SLAP_RESTRICT_EXOP_MODIFY_PASSWD 0x0200U
#define SLAP_RESTRICT_EXOP_WHOAMI 0x0400U

View File

@ -1218,8 +1218,8 @@ slapi_search_internal(
op->oq_search.rs_scope = scope;
op->oq_search.rs_deref = 0;
op->oq_search.rs_slimit = LDAP_NO_LIMIT;
op->oq_search.rs_tlimit = LDAP_NO_LIMIT;
op->oq_search.rs_slimit = SLAP_NO_LIMIT;
op->oq_search.rs_tlimit = SLAP_NO_LIMIT;
op->oq_search.rs_attrsonly = attrsonly;
op->oq_search.rs_attrs = an;
op->oq_search.rs_filter = filter;