static void
do_read( char *uri, char *entry, int maxloop,
- int maxretries, int delay );
+ int maxretries, int delay, int force );
static void
usage( char *name )
"usage: %s "
"-H <uri> | ([-h <host>] -p <port>) "
"-e <entry> "
+ "[-F] "
"[-l <loops>] "
"[-L <outerloops>] "
"[-r <maxretries>] "
int outerloops = 1;
int retries = RETRIES;
int delay = 0;
+ int force = 0;
tester_init( "slapd-read" );
- while ( (i = getopt( argc, argv, "H:h:p:e:l:L:r:t:" )) != EOF ) {
+ while ( (i = getopt( argc, argv, "H:h:p:e:Fl:L:r:t:" )) != EOF ) {
switch( i ) {
case 'H': /* the server uri */
uri = strdup( optarg );
entry = strdup( optarg );
break;
+ case 'F':
+ force++;
+ break;
+
case 'l': /* the number of loops */
if ( lutil_atoi( &loops, optarg ) != 0 ) {
usage( argv[0] );
uri = tester_uri( uri, host, port );
for ( i = 0; i < outerloops; i++ ) {
- do_read( uri, entry, loops, retries, delay );
+ do_read( uri, entry, loops, retries, delay, force );
}
exit( EXIT_SUCCESS );
static void
do_read( char *uri, char *entry, int maxloop,
- int maxretries, int delay )
+ int maxretries, int delay, int force )
{
LDAP *ld = NULL;
int i = 0, do_retry = maxretries;
int rc = LDAP_SUCCESS;
int version = LDAP_VERSION3;
struct berval passwd = { 0, "" };
+ int first = 1;
retry:;
ldap_initialize( &ld, uri );
}
for ( ; i < maxloop; i++ ) {
- LDAPMessage *res;
+ LDAPMessage *res = NULL;
rc = ldap_search_ext_s( ld, entry, LDAP_SCOPE_BASE,
NULL, attrs, 1, NULL, NULL, NULL, LDAP_NO_LIMIT, &res );
- if ( rc != LDAP_SUCCESS ) {
+ switch ( rc ) {
+ case LDAP_REFERRAL:
+ /* don't log: it's intended */
+ if ( force >= 2 ) {
+ if ( !first ) {
+ break;
+ }
+ first = 0;
+ }
+ tester_ldap_error( ld, "ldap_search_ext_s" );
+ /* fallthru */
+
+ case LDAP_SUCCESS:
+ break;
+
+ default:
tester_ldap_error( ld, "ldap_search_ext_s" );
if ( rc == LDAP_BUSY && do_retry > 0 ) {
do_retry--;
goto retry;
}
- if ( rc != LDAP_NO_SUCH_OBJECT ) break;
- continue;
-
+ if ( rc != LDAP_NO_SUCH_OBJECT ) {
+ goto done;
+ }
+ break;
}
- ldap_msgfree( res );
+ if ( res != NULL ) {
+ ldap_msgfree( res );
+ }
}
+done:;
fprintf( stderr, " PID=%ld - Read done (%d).\n", (long) pid, rc );
ldap_unbind_ext( ld, NULL, NULL );
static void
do_search( char *uri, char *manager, struct berval *passwd,
char *sbase, char *filter, LDAP **ldp,
- int innerloop, int maxretries, int delay );
+ int innerloop, int maxretries, int delay, int force );
static void
do_random( char *uri, char *manager, struct berval *passwd,
char *sbase, char *filter, char *attr, int innerloop,
- int maxretries, int delay );
+ int maxretries, int delay, int force );
static void
usage( char *name )
"-b <searchbase> "
"-f <searchfilter> "
"[-a <attr>] "
+ "[-F] "
"[-l <loops>] "
"[-L <outerloops>] "
"[-r <maxretries>] "
int outerloops = 1;
int retries = RETRIES;
int delay = 0;
+ int force = 0;
tester_init( "slapd-search" );
- while ( (i = getopt( argc, argv, "a:b:D:f:H:h:l:L:p:w:r:t:" )) != EOF ) {
+ while ( (i = getopt( argc, argv, "a:b:D:f:FH:h:l:L:p:w:r:t:" )) != EOF ) {
switch( i ) {
case 'H': /* the server uri */
uri = strdup( optarg );
filter = strdup( optarg );
break;
+ case 'F':
+ force++;
+ break;
+
case 'l': /* number of loops */
if ( lutil_atoi( &loops, optarg ) != 0 ) {
usage( argv[0] );
for ( i = 0; i < outerloops; i++ ) {
if ( attr != NULL ) {
do_random( uri, manager, &passwd, sbase, filter, attr,
- loops, retries, delay );
+ loops, retries, delay, force );
} else {
do_search( uri, manager, &passwd, sbase, filter, NULL,
- loops, retries, delay );
+ loops, retries, delay, force );
}
}
static void
do_random( char *uri, char *manager, struct berval *passwd,
char *sbase, char *filter, char *attr,
- int innerloop, int maxretries, int delay )
+ int innerloop, int maxretries, int delay, int force )
{
LDAP *ld = NULL;
int i = 0, do_retry = maxretries;
snprintf( buf, sizeof( buf ), "(%s=%s)", attr, values[ rand() % nvalues ] );
do_search( uri, manager, passwd, sbase, buf, &ld,
- 1, maxretries, delay );
+ 1, maxretries, delay, force );
}
}
static void
do_search( char *uri, char *manager, struct berval *passwd,
char *sbase, char *filter, LDAP **ldp,
- int innerloop, int maxretries, int delay )
+ int innerloop, int maxretries, int delay, int force )
{
LDAP *ld = ldp ? *ldp : NULL;
int i = 0, do_retry = maxretries;
pid_t pid = getpid();
int rc = LDAP_SUCCESS;
int version = LDAP_VERSION3;
+ int first = 1;
retry:;
if ( ld == NULL ) {
}
for ( ; i < innerloop; i++ ) {
- LDAPMessage *res;
+ LDAPMessage *res = NULL;
rc = ldap_search_ext_s( ld, sbase, LDAP_SCOPE_SUBTREE,
- filter, attrs, 0, NULL, NULL, NULL, LDAP_NO_LIMIT, &res );
- if ( rc != LDAP_SUCCESS ) {
+ filter, attrs, 0, NULL, NULL,
+ NULL, LDAP_NO_LIMIT, &res );
+ if ( res != NULL ) {
+ ldap_msgfree( res );
+ }
+
+ switch ( rc ) {
+ case LDAP_REFERRAL:
+ /* don't log: it's intended */
+ if ( force >= 2 ) {
+ if ( !first ) {
+ break;
+ }
+ first = 0;
+ }
+ tester_ldap_error( ld, "ldap_search_ext_s" );
+ /* fallthru */
+
+ case LDAP_SUCCESS:
+ break;
+
+ default:
tester_ldap_error( ld, "ldap_search_ext_s" );
if ( rc == LDAP_BUSY && do_retry > 0 ) {
ldap_unbind_ext( ld, NULL, NULL );
do_retry--;
goto retry;
}
- if ( rc != LDAP_NO_SUCH_OBJECT ) break;
- continue;
-
+ if ( rc != LDAP_NO_SUCH_OBJECT ) {
+ goto done;
+ }
+ break;
}
-
- ldap_msgfree( res );
}
-
+done:;
if ( ldp != NULL ) {
*ldp = ld;