]> git.sur5r.net Git - openldap/commitdiff
allow time/size limit errors as soon as some data is returned; don't divide by zero...
authorPierangelo Masarati <ando@openldap.org>
Tue, 4 Apr 2006 17:55:27 +0000 (17:55 +0000)
committerPierangelo Masarati <ando@openldap.org>
Tue, 4 Apr 2006 17:55:27 +0000 (17:55 +0000)
tests/progs/slapd-read.c
tests/progs/slapd-search.c

index ba610b7aa62d2c37982a4e730b1b270de67abd25..fae850381f045728263882d0eb052fb214068d9d 100644 (file)
@@ -204,7 +204,7 @@ do_random( char *uri, char *manager, struct berval *passwd,
        int     version = LDAP_VERSION3;
        int     nvalues = 0;
        char    **values = NULL;
-       LDAPMessage *res = NULL;
+       LDAPMessage *res = NULL, *e = NULL;
 
        attrs[ 0 ] = LDAP_NO_ATTRS;
        attrs[ 1 ] = NULL;
@@ -239,21 +239,22 @@ do_random( char *uri, char *manager, struct berval *passwd,
 
        rc = ldap_search_ext_s( ld, sbase, LDAP_SCOPE_SUBTREE,
                filter, attrs, 0, NULL, NULL, NULL, LDAP_NO_LIMIT, &res );
-       if ( rc != LDAP_SUCCESS ) {
-               tester_ldap_error( ld, "ldap_search_ext_s" );
-
-       } else {
+       switch ( rc ) {
+       case LDAP_SIZELIMIT_EXCEEDED:
+       case LDAP_TIMELIMIT_EXCEEDED:
+       case LDAP_SUCCESS:
                nvalues = ldap_count_entries( ld, res );
-               if ( nvalues > 0 ) {
-                       LDAPMessage     *e;
+               if ( nvalues == 0 ) {
+                       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 );
 
@@ -266,8 +267,11 @@ do_random( char *uri, char *manager, struct berval *passwd,
                                noattrs, 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 );
 
index d33fcb4afb89b8c11bb70b54433549eb7b27947e..8bb7067f4dae3ed6b4971e16aba7ef1b19b37740 100644 (file)
@@ -212,7 +212,7 @@ do_random( char *uri, char *manager, struct berval *passwd,
        int     version = LDAP_VERSION3;
        int     nvalues = 0;
        char    **values = NULL;
-       LDAPMessage *res = NULL;
+       LDAPMessage *res = NULL, *e = NULL;
 
        attrs[ 0 ] = attr;
        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,
                filter, attrs, 0, NULL, NULL, NULL, LDAP_NO_LIMIT, &res );
-       if ( rc != LDAP_SUCCESS ) {
-               tester_ldap_error( ld, "ldap_search_ext_s" );
+       switch ( rc ) {
+       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 ) )
                {
                        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,
                                        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 );