use LDAP_SIZELIMIT_EXCEEDED; rework the return values of slap_send_search_entry(); silence a few warnings

This commit is contained in:
Pierangelo Masarati 2005-11-25 22:17:24 +00:00
parent abc13afcc9
commit b3c8a976ec
13 changed files with 68 additions and 91 deletions
servers/slapd

View File

@ -696,7 +696,7 @@ aci_init( void )
&rc, &text, LDAP_SCHEMA_ALLOW_ALL );
if ( !at ) {
Debug( LDAP_DEBUG_ANY,
"%s AttributeType load failed: %s %s\n",
"aci_init: AttributeType \"%s\" parse failed: %s %s\n",
aci_at.name, ldap_scherr2str( rc ), text );
return rc;
}
@ -704,9 +704,9 @@ aci_init( void )
rc = at_add( at, 0, &sat, &text );
if ( rc != LDAP_SUCCESS ) {
ldap_attributetype_free( at );
fprintf( stderr, "iMUX_monitor_schema_init: "
"AttributeType load failed: %s %s\n",
scherr2str( rc ), text );
Debug( LDAP_DEBUG_ANY,
"aci_init: AttributeType \"%s\" load failed: %s %s\n",
aci_at.name, scherr2str( rc ), text );
return rc;
}
ldap_memfree( at );
@ -715,7 +715,7 @@ aci_init( void )
aci_at.ad, &text );
if ( rc != LDAP_SUCCESS ) {
Debug( LDAP_DEBUG_ANY,
"unable to find AttributeDescription "
"aci_init: unable to find AttributeDescription "
"\"%s\": %d (%s)\n",
aci_at.name, rc, text );
return 1;

View File

@ -325,7 +325,7 @@ parse_acl(
int pos )
{
int i;
char *left, *right, *style, *next;
char *left, *right, *style;
struct berval bv;
AccessControl *a;
Access *b;
@ -776,8 +776,6 @@ parse_acl(
} else if ( strcasecmp( style, "level" ) == 0 )
{
char *next;
if ( lutil_atoi( &level, style_level ) != 0 ) {
Debug( LDAP_DEBUG_ANY,
"%s: line %d: unable to parse level "

View File

@ -874,20 +874,20 @@ fetch_entry_retry:
if (e) {
/* safe default */
int result = -1;
rs->sr_attrs = op->oq_search.rs_attrs;
rs->sr_operational_attrs = NULL;
rs->sr_ctrls = NULL;
rs->sr_flags = 0;
rs->sr_err = LDAP_SUCCESS;
result = send_search_entry( op, rs );
rs->sr_err = send_search_entry( op, rs );
switch ( result ) {
case 0: /* entry sent ok */
switch ( rs->sr_err ) {
case LDAP_SUCCESS: /* entry sent ok */
break;
case 1: /* entry not sent */
default: /* entry not sent */
break;
default:
case LDAP_UNAVAILABLE:
case LDAP_SIZELIMIT_EXCEEDED:
#ifdef SLAP_ZONE_ALLOC
slap_zn_runlock(bdb->bi_cache.c_zctx, e);
#endif
@ -895,16 +895,13 @@ fetch_entry_retry:
&bdb->bi_cache, e, &lock);
e = NULL;
rs->sr_entry = NULL;
switch ( result ) {
case SLAPD_SEND_SIZELIMIT:
rs->sr_err = LDAP_SIZELIMIT_EXCEEDED;
if ( rs->sr_err == LDAP_SIZELIMIT_EXCEEDED ) {
rs->sr_ref = rs->sr_v2ref;
send_ldap_result( op, rs );
rs->sr_err = LDAP_SUCCESS;
break;
case -1: /* connection closed */
} else {
rs->sr_err = LDAP_OTHER;
break;
}
goto done;
}

View File

@ -286,7 +286,6 @@ retry:
} else if ( rc == LDAP_RES_SEARCH_ENTRY ) {
Entry ent = { 0 };
struct berval bdn = BER_BVNULL;
int abort = 0;
do_retry = 0;
@ -297,7 +296,7 @@ retry:
rs->sr_attrs = op->ors_attrs;
rs->sr_operational_attrs = NULL;
rs->sr_flags = 0;
abort = send_search_entry( op, rs );
rc = rs->sr_err = send_search_entry( op, rs );
if ( !BER_BVISNULL( &ent.e_name ) ) {
assert( ent.e_name.bv_val != bdn.bv_val );
free( ent.e_name.bv_val );
@ -310,11 +309,12 @@ retry:
entry_clean( &ent );
}
ldap_msgfree( res );
if ( abort ) {
if ( abort == SLAPD_SEND_SIZELIMIT ) {
rc = rs->sr_err = LDAP_SIZELIMIT_EXCEEDED;
if ( rc != LDAP_SUCCESS ) {
if ( rc == LDAP_UNAVAILABLE ) {
rc = rs->sr_err = LDAP_OTHER;
} else {
ldap_abandon_ext( lc->lc_ld, msgid, NULL, NULL );
}
ldap_abandon_ext( lc->lc_ld, msgid, NULL, NULL );
goto finish;
}

View File

@ -432,20 +432,16 @@ searchit:
if ( scopeok ) {
if (e) {
rs->sr_flags = 0;
result = send_search_entry( op, rs );
rs->sr_err = send_search_entry( op, rs );
switch ( result ) {
case 0: /* entry sent ok */
break;
case 1: /* entry not sent */
break;
case -1: /* connection closed */
switch ( rs->sr_err ) {
case LDAP_UNAVAILABLE: /* connection closed */
cache_return_entry_r( &li->li_cache, e );
rc = LDAP_SUCCESS;
goto done;
case SLAPD_SEND_SIZELIMIT:
case LDAP_SIZELIMIT_EXCEEDED:
cache_return_entry_r( &li->li_cache, e );
rc = rs->sr_err = LDAP_SIZELIMIT_EXCEEDED;
rc = rs->sr_err;
rs->sr_entry = NULL;
send_ldap_result( op, rs );
rc = LDAP_SUCCESS;

View File

@ -456,20 +456,20 @@ really_bad:;
e = ldap_first_entry( msc->msc_ld, res );
savepriv = op->o_private;
op->o_private = (void *)i;
rc = meta_send_entry( op, rs, mc, i, e );
rs->sr_err = meta_send_entry( op, rs, mc, i, e );
ldap_msgfree( res );
res = NULL;
switch ( rc ) {
case SLAPD_SEND_SIZELIMIT:
rs->sr_err = LDAP_SIZELIMIT_EXCEEDED;
case LDAP_SIZELIMIT_EXCEEDED:
savepriv = op->o_private;
op->o_private = (void *)i;
send_ldap_result( op, rs );
op->o_private = savepriv;
rs->sr_err = LDAP_SUCCESS;
goto finish;
case -1:
case LDAP_UNAVAILABLE:
rs->sr_err = LDAP_OTHER;
goto finish;
}
@ -1156,20 +1156,11 @@ next_attr:;
rs->sr_entry = &ent;
rs->sr_attrs = op->ors_attrs;
rs->sr_flags = 0;
switch ( send_search_entry( op, rs ) ) {
case 0:
case 1:
rc = LDAP_SUCCESS;
break;
case -1:
rc = send_search_entry( op, rs );
switch ( rc ) {
case LDAP_UNAVAILABLE:
rc = LDAP_OTHER;
break;
case SLAPD_SEND_SIZELIMIT:
rc = LDAP_SIZELIMIT_EXCEEDED;
break;
default:
/* trap other values when added... */
assert( 0 );
}
rs->sr_entry = NULL;
rs->sr_attrs = NULL;

View File

@ -89,11 +89,10 @@ perl_back_search(
rs->sr_entry = e;
rs->sr_attrs = op->ors_attrs;
rs->sr_flags = REP_ENTRY_MODIFIABLE;
rc = send_search_entry( op, rs );
switch ( rc ) {
case SLAPD_SEND_SIZELIMIT:
rs->sr_err = LDAP_SUCCESS;
rs->sr_err = send_search_entry( op, rs );
if ( rs->sr_err == LDAP_SIZELIMIT_EXCEEDED ) {
rs->sr_entry = NULL;
rs->sr_err = LDAP_SIZELIMIT_EXCEEDED;
goto done;
}
}

View File

@ -2325,13 +2325,13 @@ backsql_search( Operation *op, SlapReply *rs )
rs->sr_entry = e;
rs->sr_flags = ( e == &user_entry ) ? REP_ENTRY_MODIFIABLE : 0;
/* FIXME: need the whole entry (ITS#3480) */
sres = send_search_entry( op, rs );
rs->sr_err = send_search_entry( op, rs );
rs->sr_entry = NULL;
rs->sr_attrs = NULL;
rs->sr_operational_attrs = NULL;
switch ( sres ) {
case -1:
switch ( rs->sr_err ) {
case LDAP_UNAVAILABLE:
/*
* FIXME: send_search_entry failed;
* better stop
@ -2340,8 +2340,7 @@ backsql_search( Operation *op, SlapReply *rs )
"connection lost\n", 0, 0, 0 );
goto end_of_search;
case SLAPD_SEND_SIZELIMIT:
rs->sr_err = LDAP_SIZELIMIT_EXCEEDED;
case LDAP_SIZELIMIT_EXCEEDED:
goto send_results;
}
}

View File

@ -234,7 +234,7 @@ glue_op_search ( Operation *op, SlapReply *rs )
BackendInfo *bi0 = op->o_bd->bd_info;
int i;
long stoptime = 0;
glue_state gs = {0, 0, 0, NULL, 0, NULL};
glue_state gs = {0, 0, NULL, 0, NULL};
slap_callback cb = { NULL, glue_op_response, NULL, NULL };
int scope0, tlimit0;
struct berval dn, ndn, *pdn;

View File

@ -1489,7 +1489,6 @@ config_schema_dn(ConfigArgs *c) {
static int
config_sizelimit(ConfigArgs *c) {
int i, rc = 0;
char *next;
struct slap_limits_set *lim = &c->be->be_def_limit;
if (c->op == SLAP_CONFIG_EMIT) {
char buf[8192];
@ -1541,7 +1540,6 @@ config_sizelimit(ConfigArgs *c) {
static int
config_timelimit(ConfigArgs *c) {
int i, rc = 0;
char *next;
struct slap_limits_set *lim = &c->be->be_def_limit;
if (c->op == SLAP_CONFIG_EMIT) {
char buf[8192];
@ -2137,7 +2135,6 @@ static int config_syslog;
static int
config_loglevel(ConfigArgs *c) {
int i;
char *next;
if ( loglevel_ops == NULL ) {
loglevel_init();

View File

@ -114,8 +114,6 @@ retcode_send_onelevel( Operation *op, SlapReply *rs )
retcode_item_t *rdi;
for ( rdi = rd->rd_item; rdi != NULL; rdi = rdi->rdi_next ) {
int rc;
if ( op->o_abandon ) {
return rs->sr_err = SLAPD_ABANDON;
}
@ -135,20 +133,14 @@ retcode_send_onelevel( Operation *op, SlapReply *rs )
rs->sr_err = LDAP_SUCCESS;
rs->sr_entry = &rdi->rdi_e;
rc = send_search_entry( op, rs );
rs->sr_err = send_search_entry( op, rs );
rs->sr_entry = NULL;
switch ( rc ) {
case 0: /* entry sent ok */
break;
case 1: /* entry not sent */
break;
case -1: /* connection closed */
rs->sr_entry = NULL;
switch ( rs->sr_err ) {
case LDAP_UNAVAILABLE: /* connection closed */
rs->sr_err = LDAP_OTHER;
goto done;
case SLAPD_SEND_SIZELIMIT:
rs->sr_entry = NULL;
rs->sr_err = LDAP_SIZELIMIT_EXCEEDED;
/* fallthru */
case LDAP_SIZELIMIT_EXCEEDED:
goto done;
}
}

View File

@ -665,10 +665,11 @@ slap_send_ldap_intermediate( Operation *op, SlapReply *rs )
/*
* returns:
*
* 0 entry sent
* 1 entry not sent (other)
* -1 entry not sent (connection closed)
* SLAPD_SEND_SIZELIMIT entry not sent (caller must send sizelimitExceeded)
* LDAP_SUCCESS entry sent
* LDAP_OTHER entry not sent (other)
* LDAP_INSUFFICIENT_ACCESS entry not sent (ACL)
* LDAP_UNAVAILABLE entry not sent (connection closed)
* LDAP_SIZELIMIT_EXCEEDED entry not sent (caller must send sizelimitExceeded)
*/
int
@ -677,7 +678,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
BerElementBuffer berbuf;
BerElement *ber = (BerElement *) &berbuf;
Attribute *a;
int i, j, rc=-1, bytes;
int i, j, rc = LDAP_UNAVAILABLE, bytes;
char *edn;
int userattrs;
AccessControlState acl_state = ACL_STATE_INIT;
@ -691,7 +692,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
char **e_flags = NULL;
if ( op->ors_slimit >= 0 && rs->sr_nentries >= op->ors_slimit ) {
return SLAPD_SEND_SIZELIMIT;
return LDAP_SIZELIMIT_EXCEEDED;
}
rs->sr_type = REP_SEARCH;
@ -744,7 +745,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
"send_search_entry: conn %lu access to entry (%s) not allowed\n",
op->o_connid, rs->sr_entry->e_name.bv_val, 0 );
rc = 1;
rc = LDAP_INSUFFICIENT_ACCESS;
goto error_return;
}
@ -790,6 +791,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
if ( op->o_res_ber == NULL ) ber_free_buf( ber );
send_ldap_error( op, rs, LDAP_OTHER, "encoding DN error" );
rc = rs->sr_err;
goto error_return;
}
@ -837,6 +839,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
if ( op->o_res_ber == NULL ) ber_free_buf( ber );
send_ldap_error( op, rs, LDAP_OTHER,
"matched values filtering error" );
rc = rs->sr_err;
goto error_return;
}
}
@ -886,6 +889,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
if ( op->o_res_ber == NULL ) ber_free_buf( ber );
send_ldap_error( op, rs, LDAP_OTHER,
"encoding description error");
rc = rs->sr_err;
goto error_return;
}
finish = 1;
@ -919,6 +923,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
if ( op->o_res_ber == NULL ) ber_free_buf( ber );
send_ldap_error( op, rs, LDAP_OTHER,
"encoding description error");
rc = rs->sr_err;
goto error_return;
}
}
@ -930,6 +935,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
if ( op->o_res_ber == NULL ) ber_free_buf( ber );
send_ldap_error( op, rs, LDAP_OTHER,
"encoding values error" );
rc = rs->sr_err;
goto error_return;
}
}
@ -942,6 +948,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
if ( op->o_res_ber == NULL ) ber_free_buf( ber );
send_ldap_error( op, rs, LDAP_OTHER, "encode end error" );
rc = rs->sr_err;
goto error_return;
}
}
@ -995,6 +1002,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
if ( op->o_res_ber == NULL ) ber_free_buf( ber );
send_ldap_error( op, rs, LDAP_OTHER,
"matched values filtering error" );
rc = rs->sr_err;
goto error_return;
}
}
@ -1044,6 +1052,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
if ( op->o_res_ber == NULL ) ber_free_buf( ber );
send_ldap_error( op, rs, LDAP_OTHER,
"encoding description error" );
rc = rs->sr_err;
goto error_return;
}
@ -1072,6 +1081,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
if ( op->o_res_ber == NULL ) ber_free_buf( ber );
send_ldap_error( op, rs, LDAP_OTHER,
"encoding values error" );
rc = rs->sr_err;
goto error_return;
}
}
@ -1084,6 +1094,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
if ( op->o_res_ber == NULL ) ber_free_buf( ber );
send_ldap_error( op, rs, LDAP_OTHER, "encode end error" );
rc = rs->sr_err;
goto error_return;
}
}
@ -1118,7 +1129,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
if ( op->o_res_ber == NULL ) ber_free_buf( ber );
send_ldap_error( op, rs, LDAP_OTHER, "encode entry end error" );
rc = 1;
rc = rs->sr_err;
goto error_return;
}
@ -1137,7 +1148,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
"send_search_entry: conn %lu ber write failed.\n",
op->o_connid, 0, 0 );
rc = -1;
rc = LDAP_UNAVAILABLE;
goto error_return;
}
rs->sr_nentries++;
@ -1155,7 +1166,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
Debug( LDAP_DEBUG_TRACE,
"<= send_search_entry: conn %lu exit.\n", op->o_connid, 0, 0 );
rc = 0;
rc = LDAP_SUCCESS;
error_return:;
if ( op->o_callback ) {

View File

@ -153,9 +153,6 @@ LDAP_BEGIN_DECL
/* unknown config file directive */
#define SLAP_CONF_UNKNOWN (-1026)
/* pseudo error code indicating caller should send sizelimitExceeded */
#define SLAPD_SEND_SIZELIMIT (-1027)
/* We assume "C" locale, that is US-ASCII */
#define ASCII_SPACE(c) ( (c) == ' ' )
#define ASCII_LOWER(c) ( (c) >= 'a' && (c) <= 'z' )