mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-01-06 10:46:21 +08:00
allow time/size limit errors as soon as some data is returned; don't divide by zero if no entries were found
This commit is contained in:
parent
543396c804
commit
6d357288d6
@ -204,7 +204,7 @@ do_random( char *uri, char *manager, struct berval *passwd,
|
|||||||
int version = LDAP_VERSION3;
|
int version = LDAP_VERSION3;
|
||||||
int nvalues = 0;
|
int nvalues = 0;
|
||||||
char **values = NULL;
|
char **values = NULL;
|
||||||
LDAPMessage *res = NULL;
|
LDAPMessage *res = NULL, *e = NULL;
|
||||||
|
|
||||||
attrs[ 0 ] = LDAP_NO_ATTRS;
|
attrs[ 0 ] = LDAP_NO_ATTRS;
|
||||||
attrs[ 1 ] = NULL;
|
attrs[ 1 ] = NULL;
|
||||||
@ -239,22 +239,23 @@ do_random( char *uri, char *manager, struct berval *passwd,
|
|||||||
|
|
||||||
rc = ldap_search_ext_s( ld, sbase, LDAP_SCOPE_SUBTREE,
|
rc = ldap_search_ext_s( ld, sbase, LDAP_SCOPE_SUBTREE,
|
||||||
filter, attrs, 0, NULL, NULL, NULL, LDAP_NO_LIMIT, &res );
|
filter, attrs, 0, NULL, NULL, NULL, LDAP_NO_LIMIT, &res );
|
||||||
if ( rc != LDAP_SUCCESS ) {
|
switch ( rc ) {
|
||||||
tester_ldap_error( ld, "ldap_search_ext_s" );
|
case LDAP_SIZELIMIT_EXCEEDED:
|
||||||
|
case LDAP_TIMELIMIT_EXCEEDED:
|
||||||
} else {
|
case LDAP_SUCCESS:
|
||||||
nvalues = ldap_count_entries( ld, res );
|
nvalues = ldap_count_entries( ld, res );
|
||||||
if ( nvalues > 0 ) {
|
if ( nvalues == 0 ) {
|
||||||
LDAPMessage *e;
|
break;
|
||||||
|
|
||||||
values = malloc( ( nvalues + 1 ) * sizeof( char * ) );
|
|
||||||
for ( i = 0, e = ldap_first_entry( ld, res ); e != NULL; i++, e = ldap_next_entry( ld, e ) )
|
|
||||||
{
|
|
||||||
values[ i ] = ldap_get_dn( ld, e );
|
|
||||||
}
|
|
||||||
values[ i ] = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
values = malloc( ( nvalues + 1 ) * sizeof( char * ) );
|
||||||
|
for ( i = 0, e = ldap_first_entry( ld, res ); e != NULL; i++, e = ldap_next_entry( ld, e ) )
|
||||||
|
{
|
||||||
|
values[ i ] = ldap_get_dn( ld, e );
|
||||||
|
}
|
||||||
|
values[ i ] = NULL;
|
||||||
|
|
||||||
ldap_msgfree( res );
|
ldap_msgfree( res );
|
||||||
|
|
||||||
if ( do_retry == maxretries ) {
|
if ( do_retry == maxretries ) {
|
||||||
@ -266,8 +267,11 @@ do_random( char *uri, char *manager, struct berval *passwd,
|
|||||||
noattrs, 1, maxretries, delay, force,
|
noattrs, 1, maxretries, delay, force,
|
||||||
chaserefs );
|
chaserefs );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
tester_ldap_error( ld, "ldap_search_ext_s" );
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fprintf( stderr, " PID=%ld - Search done (%d).\n", (long) pid, rc );
|
fprintf( stderr, " PID=%ld - Search done (%d).\n", (long) pid, rc );
|
||||||
|
|
||||||
|
@ -212,7 +212,7 @@ do_random( char *uri, char *manager, struct berval *passwd,
|
|||||||
int version = LDAP_VERSION3;
|
int version = LDAP_VERSION3;
|
||||||
int nvalues = 0;
|
int nvalues = 0;
|
||||||
char **values = NULL;
|
char **values = NULL;
|
||||||
LDAPMessage *res = NULL;
|
LDAPMessage *res = NULL, *e = NULL;
|
||||||
|
|
||||||
attrs[ 0 ] = attr;
|
attrs[ 0 ] = attr;
|
||||||
attrs[ 1 ] = NULL;
|
attrs[ 1 ] = NULL;
|
||||||
@ -247,11 +247,14 @@ do_random( char *uri, char *manager, struct berval *passwd,
|
|||||||
|
|
||||||
rc = ldap_search_ext_s( ld, sbase, LDAP_SCOPE_SUBTREE,
|
rc = ldap_search_ext_s( ld, sbase, LDAP_SCOPE_SUBTREE,
|
||||||
filter, attrs, 0, NULL, NULL, NULL, LDAP_NO_LIMIT, &res );
|
filter, attrs, 0, NULL, NULL, NULL, LDAP_NO_LIMIT, &res );
|
||||||
if ( rc != LDAP_SUCCESS ) {
|
switch ( rc ) {
|
||||||
tester_ldap_error( ld, "ldap_search_ext_s" );
|
case LDAP_SIZELIMIT_EXCEEDED:
|
||||||
|
case LDAP_TIMELIMIT_EXCEEDED:
|
||||||
|
case LDAP_SUCCESS:
|
||||||
|
if ( ldap_count_entries( ld, res ) == 0 ) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
|
||||||
LDAPMessage *e;
|
|
||||||
for ( e = ldap_first_entry( ld, res ); e != NULL; e = ldap_next_entry( ld, e ) )
|
for ( e = ldap_first_entry( ld, res ); e != NULL; e = ldap_next_entry( ld, e ) )
|
||||||
{
|
{
|
||||||
struct berval **v = ldap_get_values_len( ld, e, attr );
|
struct berval **v = ldap_get_values_len( ld, e, attr );
|
||||||
@ -284,8 +287,11 @@ do_random( char *uri, char *manager, struct berval *passwd,
|
|||||||
do_search( uri, manager, passwd, sbase, buf, &ld, noattrs,
|
do_search( uri, manager, passwd, sbase, buf, &ld, noattrs,
|
||||||
1, maxretries, delay, force, chaserefs );
|
1, maxretries, delay, force, chaserefs );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
tester_ldap_error( ld, "ldap_search_ext_s" );
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fprintf( stderr, " PID=%ld - Search done (%d).\n", (long) pid, rc );
|
fprintf( stderr, " PID=%ld - Search done (%d).\n", (long) pid, rc );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user