add "retry" switch (currently needed to stress-test back-meta); defaults to old behavior

This commit is contained in:
Pierangelo Masarati 2005-04-20 16:16:39 +00:00
parent 7496ebeb35
commit c66a92f935
6 changed files with 357 additions and 227 deletions

View file

@ -34,13 +34,14 @@
#include <ldap.h> #include <ldap.h>
#define LOOPS 100 #define LOOPS 100
#define RETRIES 0
static char * static char *
get_add_entry( char *filename, LDAPMod ***mods ); get_add_entry( char *filename, LDAPMod ***mods );
static void static void
do_addel( char *uri, char *host, int port, char *manager, char *passwd, do_addel( char *uri, char *host, int port, char *manager, char *passwd,
char *dn, LDAPMod **attrs, int maxloop ); char *dn, LDAPMod **attrs, int maxloop, int maxretries );
static void static void
usage( char *name ) usage( char *name )
@ -62,13 +63,15 @@ main( int argc, char **argv )
char *filename = NULL; char *filename = NULL;
char *entry = NULL; char *entry = NULL;
int loops = LOOPS; int loops = LOOPS;
int retries = RETRIES;
LDAPMod **attrs = NULL; LDAPMod **attrs = NULL;
while ( (i = getopt( argc, argv, "H:h:p:D:w:f:l:" )) != EOF ) { while ( (i = getopt( argc, argv, "H:h:p:D:w:f:l:r:" )) != EOF ) {
switch( i ) { switch( i ) {
case 'H': /* the server's URI */ case 'H': /* the server's URI */
uri = strdup( optarg ); uri = strdup( optarg );
break; break;
case 'h': /* the servers host */ case 'h': /* the servers host */
host = strdup( optarg ); host = strdup( optarg );
break; break;
@ -93,6 +96,10 @@ main( int argc, char **argv )
loops = atoi( optarg ); loops = atoi( optarg );
break; break;
case 'r':
retries = atoi( optarg );
break;
default: default:
usage( argv[0] ); usage( argv[0] );
break; break;
@ -120,7 +127,8 @@ main( int argc, char **argv )
} }
do_addel( uri, host, port, manager, passwd, entry, attrs, loops ); do_addel( uri, host, port, manager, passwd, entry, attrs,
loops, retries );
exit( EXIT_SUCCESS ); exit( EXIT_SUCCESS );
} }
@ -249,14 +257,16 @@ do_addel(
char *passwd, char *passwd,
char *entry, char *entry,
LDAPMod **attrs, LDAPMod **attrs,
int maxloop int maxloop,
int maxretries
) )
{ {
LDAP *ld = NULL; LDAP *ld = NULL;
int i; int i = 0, do_retry = maxretries;
pid_t pid = getpid(); pid_t pid = getpid();
int rc = LDAP_SUCCESS; int rc = LDAP_SUCCESS;
retry:;
if ( uri ) { if ( uri ) {
ldap_initialize( &ld, uri ); ldap_initialize( &ld, uri );
} else { } else {
@ -273,22 +283,31 @@ do_addel(
&version ); &version );
} }
if ( ldap_bind_s( ld, manager, passwd, LDAP_AUTH_SIMPLE ) if ( do_retry == maxretries ) {
!= LDAP_SUCCESS ) { fprintf( stderr, "PID=%ld - Add/Delete(%d): entry=\"%s\".\n",
(long) pid, maxloop, entry );
}
rc = ldap_bind_s( ld, manager, passwd, LDAP_AUTH_SIMPLE );
if ( rc != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_bind" ); ldap_perror( ld, "ldap_bind" );
if ( rc == LDAP_BUSY && do_retry > 0 ) {
do_retry--;
goto retry;
}
exit( EXIT_FAILURE ); exit( EXIT_FAILURE );
} }
for ( ; i < maxloop; i++ ) {
fprintf( stderr, "PID=%ld - Add/Delete(%d): entry=\"%s\".\n",
(long) pid, maxloop, entry );
for ( i = 0; i < maxloop; i++ ) {
/* add the entry */ /* add the entry */
rc = ldap_add_s( ld, entry, attrs ); rc = ldap_add_s( ld, entry, attrs );
if ( rc != LDAP_SUCCESS ) { if ( rc != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_add" ); ldap_perror( ld, "ldap_add" );
if ( rc == LDAP_BUSY && do_retry > 0 ) {
do_retry--;
goto retry;
}
break; break;
} }
@ -303,10 +322,12 @@ do_addel(
rc = ldap_delete_s( ld, entry ); rc = ldap_delete_s( ld, entry );
if ( rc != LDAP_SUCCESS ) { if ( rc != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_delete" ); ldap_perror( ld, "ldap_delete" );
break; if ( rc == LDAP_BUSY && do_retry > 0 ) {
do_retry--;
goto retry;
}
break;
} }
} }
fprintf( stderr, " PID=%ld - Add/Delete done (%d).\n", (long) pid, rc ); fprintf( stderr, " PID=%ld - Add/Delete done (%d).\n", (long) pid, rc );

View file

@ -30,10 +30,12 @@
#include <ldap.h> #include <ldap.h>
#define LOOPS 100 #define LOOPS 100
#define RETRIES 0
static void static void
do_modify( char *uri, char *host, int port, char *manager, char *passwd, char *entry, do_modify( char *uri, char *host, int port, char *manager, char *passwd,
char *attr, char *value, int maxloop ); char *entry, char *attr, char *value, int maxloop,
int maxretries );
static void static void
@ -57,12 +59,14 @@ main( int argc, char **argv )
char *ava = NULL; char *ava = NULL;
char *value = NULL; char *value = NULL;
int loops = LOOPS; int loops = LOOPS;
int retries = RETRIES;
while ( (i = getopt( argc, argv, "H:h:p:D:w:e:a:l:" )) != EOF ) { while ( (i = getopt( argc, argv, "H:h:p:D:w:e:a:l:r:" )) != EOF ) {
switch( i ) { switch( i ) {
case 'H': /* the server uri */ case 'H': /* the server uri */
uri = strdup( optarg ); uri = strdup( optarg );
break; break;
case 'h': /* the servers host */ case 'h': /* the servers host */
host = strdup( optarg ); host = strdup( optarg );
break; break;
@ -70,6 +74,7 @@ main( int argc, char **argv )
case 'p': /* the servers port */ case 'p': /* the servers port */
port = atoi( optarg ); port = atoi( optarg );
break; break;
case 'D': /* the servers manager */ case 'D': /* the servers manager */
manager = strdup( optarg ); manager = strdup( optarg );
break; break;
@ -77,16 +82,23 @@ main( int argc, char **argv )
case 'w': /* the server managers password */ case 'w': /* the server managers password */
passwd = strdup( optarg ); passwd = strdup( optarg );
break; break;
case 'e': /* entry to modify */ case 'e': /* entry to modify */
entry = strdup( optarg ); entry = strdup( optarg );
break; break;
case 'a': case 'a':
ava = strdup( optarg ); ava = strdup( optarg );
break; break;
case 'l': /* the number of loops */ case 'l': /* the number of loops */
loops = atoi( optarg ); loops = atoi( optarg );
break; break;
case 'r':
retries = atoi( optarg );
break;
default: default:
usage( argv[0] ); usage( argv[0] );
break; break;
@ -118,17 +130,19 @@ main( int argc, char **argv )
while ( *value && isspace( (unsigned char) *value )) while ( *value && isspace( (unsigned char) *value ))
value++; value++;
do_modify( uri, host, port, manager, passwd, entry, ava, value, loops ); do_modify( uri, host, port, manager, passwd, entry, ava, value,
loops, retries );
exit( EXIT_SUCCESS ); exit( EXIT_SUCCESS );
} }
static void static void
do_modify( char *uri, char *host, int port, char *manager, do_modify( char *uri, char *host, int port, char *manager,
char *passwd, char *entry, char* attr, char* value, int maxloop ) char *passwd, char *entry, char* attr, char* value,
int maxloop, int maxretries )
{ {
LDAP *ld = NULL; LDAP *ld = NULL;
int i; int i = 0, do_retry = maxretries;
pid_t pid; pid_t pid;
int rc = LDAP_SUCCESS; int rc = LDAP_SUCCESS;
@ -144,7 +158,7 @@ do_modify( char *uri, char *host, int port, char *manager,
mods[0] = &mod; mods[0] = &mod;
mods[1] = NULL; mods[1] = NULL;
retry:;
if ( uri ) { if ( uri ) {
ldap_initialize( &ld, uri ); ldap_initialize( &ld, uri );
} else { } else {
@ -161,26 +175,42 @@ do_modify( char *uri, char *host, int port, char *manager,
&version ); &version );
} }
if ( ldap_bind_s( ld, manager, passwd, LDAP_AUTH_SIMPLE ) != LDAP_SUCCESS ) { if ( do_retry == maxretries ) {
fprintf( stderr, "PID=%ld - Modify(%d): entry=\"%s\".\n",
(long) pid, maxloop, entry );
}
rc = ldap_bind_s( ld, manager, passwd, LDAP_AUTH_SIMPLE );
if ( rc != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_bind" ); ldap_perror( ld, "ldap_bind" );
if ( rc == LDAP_BUSY && do_retry > 0 ) {
do_retry--;
goto retry;
}
exit( EXIT_FAILURE ); exit( EXIT_FAILURE );
} }
fprintf( stderr, "PID=%ld - Modify(%d): entry=\"%s\".\n",
(long) pid, maxloop, entry );
for ( i = 0; i < maxloop; i++ ) { for ( i = 0; i < maxloop; i++ ) {
mod.mod_op = LDAP_MOD_ADD; mod.mod_op = LDAP_MOD_ADD;
if (( rc = ldap_modify_s( ld, entry, mods )) != LDAP_SUCCESS ) { rc = ldap_modify_s( ld, entry, mods );
if ( rc != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_modify" ); ldap_perror( ld, "ldap_modify" );
if ( rc == LDAP_BUSY && do_retry > 0 ) {
do_retry--;
goto retry;
}
if ( rc != LDAP_NO_SUCH_OBJECT ) break; if ( rc != LDAP_NO_SUCH_OBJECT ) break;
continue; continue;
} }
mod.mod_op = LDAP_MOD_DELETE; mod.mod_op = LDAP_MOD_DELETE;
if (( rc = ldap_modify_s( ld, entry, mods )) != LDAP_SUCCESS ) { rc = ldap_modify_s( ld, entry, mods );
if ( rc != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_modify" ); ldap_perror( ld, "ldap_modify" );
if ( rc == LDAP_BUSY && do_retry > 0 ) {
do_retry--;
goto retry;
}
if ( rc != LDAP_NO_SUCH_OBJECT ) break; if ( rc != LDAP_NO_SUCH_OBJECT ) break;
continue; continue;
} }

View file

@ -34,9 +34,11 @@
#include <ldap.h> #include <ldap.h>
#define LOOPS 100 #define LOOPS 100
#define RETRIES 0
static void static void
do_modrdn( char *uri, char *host, int port, char *manager, char *passwd, char *entry, int maxloop ); do_modrdn( char *uri, char *host, int port, char *manager, char *passwd,
char *entry, int maxloop, int maxretries );
static void static void
usage( char *name ) usage( char *name )
@ -57,12 +59,14 @@ main( int argc, char **argv )
char *passwd = NULL; char *passwd = NULL;
char *entry = NULL; char *entry = NULL;
int loops = LOOPS; int loops = LOOPS;
int retries = RETRIES;
while ( (i = getopt( argc, argv, "H:h:p:D:w:e:l:" )) != EOF ) { while ( (i = getopt( argc, argv, "H:h:p:D:w:e:l:r:" )) != EOF ) {
switch( i ) { switch( i ) {
case 'H': /* the server uri */ case 'H': /* the server uri */
uri = strdup( optarg ); uri = strdup( optarg );
break; break;
case 'h': /* the servers host */ case 'h': /* the servers host */
host = strdup( optarg ); host = strdup( optarg );
break; break;
@ -70,6 +74,7 @@ main( int argc, char **argv )
case 'p': /* the servers port */ case 'p': /* the servers port */
port = atoi( optarg ); port = atoi( optarg );
break; break;
case 'D': /* the servers manager */ case 'D': /* the servers manager */
manager = strdup( optarg ); manager = strdup( optarg );
break; break;
@ -77,6 +82,7 @@ main( int argc, char **argv )
case 'w': /* the server managers password */ case 'w': /* the server managers password */
passwd = strdup( optarg ); passwd = strdup( optarg );
break; break;
case 'e': /* entry to rename */ case 'e': /* entry to rename */
entry = strdup( optarg ); entry = strdup( optarg );
break; break;
@ -85,6 +91,10 @@ main( int argc, char **argv )
loops = atoi( optarg ); loops = atoi( optarg );
break; break;
case 'r': /* the number of retries */
retries = atoi( optarg );
break;
default: default:
usage( argv[0] ); usage( argv[0] );
break; break;
@ -102,17 +112,17 @@ main( int argc, char **argv )
} }
do_modrdn( uri, host, port, manager, passwd, entry, loops ); do_modrdn( uri, host, port, manager, passwd, entry, loops, retries );
exit( EXIT_SUCCESS ); exit( EXIT_SUCCESS );
} }
static void static void
do_modrdn( char *uri, char *host, int port, char *manager, do_modrdn( char *uri, char *host, int port, char *manager,
char *passwd, char *entry, int maxloop ) char *passwd, char *entry, int maxloop, int maxretries )
{ {
LDAP *ld = NULL; LDAP *ld = NULL;
int i; int i = 0, do_retry = maxretries;
pid_t pid; pid_t pid;
char *DNs[2]; char *DNs[2];
char *rdns[2]; char *rdns[2];
@ -142,6 +152,7 @@ do_modrdn( char *uri, char *host, int port, char *manager,
DNs[1][i] = ','; DNs[1][i] = ',';
} }
retry:;
if ( uri ) { if ( uri ) {
ldap_initialize( &ld, uri ); ldap_initialize( &ld, uri );
} else { } else {
@ -158,25 +169,39 @@ do_modrdn( char *uri, char *host, int port, char *manager,
&version ); &version );
} }
if ( ldap_bind_s( ld, manager, passwd, LDAP_AUTH_SIMPLE ) != LDAP_SUCCESS ) { if ( do_retry == maxretries ) {
fprintf( stderr, "PID=%ld - Modrdn(%d): entry=\"%s\".\n",
(long) pid, maxloop, entry );
}
rc = ldap_bind_s( ld, manager, passwd, LDAP_AUTH_SIMPLE );
if ( rc != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_bind" ); ldap_perror( ld, "ldap_bind" );
if ( rc == LDAP_BUSY && do_retry > 0 ) {
do_retry--;
goto retry;
}
exit( EXIT_FAILURE ); exit( EXIT_FAILURE );
} }
fprintf( stderr, "PID=%ld - Modrdn(%d): entry=\"%s\".\n",
(long) pid, maxloop, entry );
for ( i = 0; i < maxloop; i++ ) { for ( i = 0; i < maxloop; i++ ) {
if (( rc = ldap_modrdn2_s( ld, DNs[0], rdns[0], 0 )) rc = ldap_modrdn2_s( ld, DNs[0], rdns[0], 0 );
!= LDAP_SUCCESS ) { if ( rc != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_modrdn" ); ldap_perror( ld, "ldap_modrdn" );
if ( rc == LDAP_BUSY && do_retry > 0 ) {
do_retry--;
goto retry;
}
if ( rc != LDAP_NO_SUCH_OBJECT ) break; if ( rc != LDAP_NO_SUCH_OBJECT ) break;
continue; continue;
} }
if (( rc = ldap_modrdn2_s( ld, DNs[1], rdns[1], 1 )) rc = ldap_modrdn2_s( ld, DNs[1], rdns[1], 1 );
!= LDAP_SUCCESS ) { if ( rc != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_modrdn" ); ldap_perror( ld, "ldap_modrdn" );
if ( rc == LDAP_BUSY && do_retry > 0 ) {
do_retry--;
goto retry;
}
if ( rc != LDAP_NO_SUCH_OBJECT ) break; if ( rc != LDAP_NO_SUCH_OBJECT ) break;
continue; continue;
} }

View file

@ -34,9 +34,11 @@
#include <ldap.h> #include <ldap.h>
#define LOOPS 100 #define LOOPS 100
#define RETRIES 0
static void static void
do_read( char *uri, char *host, int port, char *entry, int maxloop ); do_read( char *uri, char *host, int port, char *entry, int maxloop,
int maxretries );
static void static void
usage( char *name ) usage( char *name )
@ -55,12 +57,14 @@ main( int argc, char **argv )
int port = -1; int port = -1;
char *entry = NULL; char *entry = NULL;
int loops = LOOPS; int loops = LOOPS;
int retries = RETRIES;
while ( (i = getopt( argc, argv, "H:h:p:e:l:" )) != EOF ) { while ( (i = getopt( argc, argv, "H:h:p:e:l:r:" )) != EOF ) {
switch( i ) { switch( i ) {
case 'H': /* the server uri */ case 'H': /* the server uri */
uri = strdup( optarg ); uri = strdup( optarg );
break; break;
case 'h': /* the servers host */ case 'h': /* the servers host */
host = strdup( optarg ); host = strdup( optarg );
break; break;
@ -69,7 +73,7 @@ main( int argc, char **argv )
port = atoi( optarg ); port = atoi( optarg );
break; break;
case 'e': /* file with entry search request */ case 'e': /* DN to search for */
entry = strdup( optarg ); entry = strdup( optarg );
break; break;
@ -77,6 +81,10 @@ main( int argc, char **argv )
loops = atoi( optarg ); loops = atoi( optarg );
break; break;
case 'r': /* the number of retries */
retries = atoi( optarg );
break;
default: default:
usage( argv[0] ); usage( argv[0] );
break; break;
@ -87,27 +95,27 @@ main( int argc, char **argv )
usage( argv[0] ); usage( argv[0] );
if ( *entry == '\0' ) { if ( *entry == '\0' ) {
fprintf( stderr, "%s: invalid EMPTY entry DN.\n", fprintf( stderr, "%s: invalid EMPTY entry DN.\n",
argv[0] ); argv[0] );
exit( EXIT_FAILURE ); exit( EXIT_FAILURE );
} }
do_read( uri, host, port, entry, ( 20 * loops )); do_read( uri, host, port, entry, ( 20 * loops ), retries );
exit( EXIT_SUCCESS ); exit( EXIT_SUCCESS );
} }
static void static void
do_read( char *uri, char *host, int port, char *entry, int maxloop ) do_read( char *uri, char *host, int port, char *entry, int maxloop,
int maxretries )
{ {
LDAP *ld = NULL; LDAP *ld = NULL;
int i; int i = 0, do_retry = maxretries;
char *attrs[] = { "1.1", NULL }; char *attrs[] = { "1.1", NULL };
pid_t pid = getpid(); pid_t pid = getpid();
int rc = LDAP_SUCCESS; int rc = LDAP_SUCCESS;
retry:;
if ( uri ) { if ( uri ) {
ldap_initialize( &ld, uri ); ldap_initialize( &ld, uri );
} else { } else {
@ -124,22 +132,32 @@ do_read( char *uri, char *host, int port, char *entry, int maxloop )
&version ); &version );
} }
if ( ldap_bind_s( ld, NULL, NULL, LDAP_AUTH_SIMPLE ) != LDAP_SUCCESS ) { if ( do_retry == maxretries ) {
fprintf( stderr, "PID=%ld - Read(%d): entry=\"%s\".\n",
(long) pid, maxloop, entry );
}
rc = ldap_bind_s( ld, NULL, NULL, LDAP_AUTH_SIMPLE );
if ( rc != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_bind" ); ldap_perror( ld, "ldap_bind" );
if ( rc == LDAP_BUSY && do_retry > 0 ) {
do_retry--;
goto retry;
}
exit( EXIT_FAILURE ); exit( EXIT_FAILURE );
} }
for ( ; i < maxloop; i++ ) {
fprintf( stderr, "PID=%ld - Read(%d): entry=\"%s\".\n",
(long) pid, maxloop, entry );
for ( i = 0; i < maxloop; i++ ) {
LDAPMessage *res; LDAPMessage *res;
rc = ldap_search_s( ld, entry, LDAP_SCOPE_BASE, rc = ldap_search_s( ld, entry, LDAP_SCOPE_BASE,
NULL, attrs, 1, &res ); NULL, attrs, 1, &res );
if ( rc != LDAP_SUCCESS ) { if ( rc != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_read" ); ldap_perror( ld, "ldap_read" );
if ( rc == LDAP_BUSY && do_retry > 0 ) {
do_retry--;
goto retry;
}
if ( rc != LDAP_NO_SUCH_OBJECT ) break; if ( rc != LDAP_NO_SUCH_OBJECT ) break;
continue; continue;
@ -153,4 +171,3 @@ do_read( char *uri, char *host, int port, char *entry, int maxloop )
ldap_unbind( ld ); ldap_unbind( ld );
} }

View file

@ -34,9 +34,11 @@
#include <ldap.h> #include <ldap.h>
#define LOOPS 100 #define LOOPS 100
#define RETRIES 0
static void static void
do_search( char *uri, char *host, int port, char *manager, char *passwd, char *sbase, char *filter, int maxloop ); do_search( char *uri, char *host, int port, char *manager, char *passwd,
char *sbase, char *filter, int maxloop, int maxretries );
static void static void
usage( char *name ) usage( char *name )
@ -58,12 +60,14 @@ main( int argc, char **argv )
char *sbase = NULL; char *sbase = NULL;
char *filter = NULL; char *filter = NULL;
int loops = LOOPS; int loops = LOOPS;
int retries = RETRIES;
while ( (i = getopt( argc, argv, "b:D:f:H:h:l:p:w:" )) != EOF ) { while ( (i = getopt( argc, argv, "b:D:f:H:h:l:p:w:r:" )) != EOF ) {
switch( i ) { switch( i ) {
case 'H': /* the server uri */ case 'H': /* the server uri */
uri = strdup( optarg ); uri = strdup( optarg );
break; break;
case 'h': /* the servers host */ case 'h': /* the servers host */
host = strdup( optarg ); host = strdup( optarg );
break; break;
@ -92,6 +96,10 @@ main( int argc, char **argv )
loops = atoi( optarg ); loops = atoi( optarg );
break; break;
case 'r': /* number of retries */
retries = atoi( optarg );
break;
default: default:
usage( argv[0] ); usage( argv[0] );
break; break;
@ -109,20 +117,23 @@ main( int argc, char **argv )
} }
do_search( uri, host, port, manager, passwd, sbase, filter, ( 10 * loops )); do_search( uri, host, port, manager, passwd, sbase, filter,
( 10 * loops ), retries );
exit( EXIT_SUCCESS ); exit( EXIT_SUCCESS );
} }
static void static void
do_search( char *uri, char *host, int port, char *manager, char *passwd, char *sbase, char *filter, int maxloop ) do_search( char *uri, char *host, int port, char *manager, char *passwd,
char *sbase, char *filter, int maxloop, int maxretries )
{ {
LDAP *ld = NULL; LDAP *ld = NULL;
int i; int i = 0, do_retry = maxretries;
char *attrs[] = { "cn", "sn", NULL }; char *attrs[] = { "cn", "sn", NULL };
pid_t pid = getpid(); pid_t pid = getpid();
int rc = LDAP_SUCCESS; int rc = LDAP_SUCCESS;
retry:;
if ( uri ) { if ( uri ) {
ldap_initialize( &ld, uri ); ldap_initialize( &ld, uri );
} else { } else {
@ -139,15 +150,21 @@ do_search( char *uri, char *host, int port, char *manager, char *passwd, char *s
&version ); &version );
} }
if ( ldap_bind_s( ld, manager, passwd, LDAP_AUTH_SIMPLE ) != LDAP_SUCCESS ) { if ( do_retry == maxretries ) {
fprintf( stderr, "PID=%ld - Search(%d): base=\"%s\", filter=\"%s\".\n",
(long) pid, maxloop, sbase, filter );
}
rc = ldap_bind_s( ld, manager, passwd, LDAP_AUTH_SIMPLE );
if ( rc != LDAP_SUCCESS ) {
if ( rc == LDAP_BUSY && do_retry == 1 ) {
do_retry = 0;
goto retry;
}
ldap_perror( ld, "ldap_bind" ); ldap_perror( ld, "ldap_bind" );
exit( EXIT_FAILURE ); exit( EXIT_FAILURE );
} }
fprintf( stderr, "PID=%ld - Search(%d): base=\"%s\", filter=\"%s\".\n",
(long) pid, maxloop, sbase, filter );
for ( i = 0; i < maxloop; i++ ) { for ( i = 0; i < maxloop; i++ ) {
LDAPMessage *res; LDAPMessage *res;
@ -155,6 +172,10 @@ do_search( char *uri, char *host, int port, char *manager, char *passwd, char *s
filter, attrs, 0, &res ); filter, attrs, 0, &res );
if ( rc != LDAP_SUCCESS ) { if ( rc != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_search" ); ldap_perror( ld, "ldap_search" );
if ( rc == LDAP_BUSY && do_retry == 1 ) {
do_retry = 0;
goto retry;
}
if ( rc != LDAP_NO_SUCH_OBJECT ) break; if ( rc != LDAP_NO_SUCH_OBJECT ) break;
continue; continue;

View file

@ -43,6 +43,7 @@
#define MAXARGS 100 #define MAXARGS 100
#define MAXREQS 5000 #define MAXREQS 5000
#define LOOPS "100" #define LOOPS "100"
#define RETRIES "0"
#define TSEARCHFILE "do_search.0" #define TSEARCHFILE "do_search.0"
#define TREADFILE "do_read.0" #define TREADFILE "do_read.0"
@ -86,6 +87,7 @@ main( int argc, char **argv )
char *dirname = NULL; char *dirname = NULL;
char *progdir = NULL; char *progdir = NULL;
char *loops = LOOPS; char *loops = LOOPS;
char *retries = RETRIES;
DIR *datadir; DIR *datadir;
struct dirent *file; struct dirent *file;
char *sfile = NULL; char *sfile = NULL;
@ -120,8 +122,16 @@ main( int argc, char **argv )
char *moddn[MAXREQS]; char *moddn[MAXREQS];
int modnum = 0; int modnum = 0;
while ( (i = getopt( argc, argv, "H:h:p:D:w:b:d:j:l:P:" )) != EOF ) { while ( (i = getopt( argc, argv, "D:d:H:h:j:l:P:p:r:w:" )) != EOF ) {
switch( i ) { switch( i ) {
case 'D': /* slapd manager */
manager = ArgDup( optarg );
break;
case 'd': /* data directory */
dirname = strdup( optarg );
break;
case 'H': /* slapd uri */ case 'H': /* slapd uri */
uri = strdup( optarg ); uri = strdup( optarg );
break; break;
@ -130,26 +140,6 @@ main( int argc, char **argv )
host = strdup( optarg ); host = strdup( optarg );
break; break;
case 'p': /* the servers port number */
port = strdup( optarg );
break;
case 'D': /* slapd manager */
manager = ArgDup( optarg );
break;
case 'w': /* the managers passwd */
passwd = ArgDup( optarg );
break;
case 'd': /* data directory */
dirname = strdup( optarg );
break;
case 'P': /* prog directory */
progdir = strdup( optarg );
break;
case 'j': /* the number of parallel clients */ case 'j': /* the number of parallel clients */
maxkids = atoi( optarg ); maxkids = atoi( optarg );
break; break;
@ -158,6 +148,22 @@ main( int argc, char **argv )
loops = strdup( optarg ); loops = strdup( optarg );
break; break;
case 'P': /* prog directory */
progdir = strdup( optarg );
break;
case 'p': /* the servers port number */
port = strdup( optarg );
break;
case 'r':
retries = strdup( optarg );
break;
case 'w': /* the managers passwd */
passwd = ArgDup( optarg );
break;
default: default:
usage( argv[0] ); usage( argv[0] );
break; break;
@ -246,6 +252,8 @@ main( int argc, char **argv )
sargs[sanum++] = passwd; sargs[sanum++] = passwd;
sargs[sanum++] = "-l"; sargs[sanum++] = "-l";
sargs[sanum++] = loops; sargs[sanum++] = loops;
sargs[sanum++] = "-r";
sargs[sanum++] = retries;
sargs[sanum++] = "-b"; sargs[sanum++] = "-b";
sargs[sanum++] = NULL; /* will hold the search base */ sargs[sanum++] = NULL; /* will hold the search base */
sargs[sanum++] = "-f"; sargs[sanum++] = "-f";
@ -271,6 +279,8 @@ main( int argc, char **argv )
} }
rargs[ranum++] = "-l"; rargs[ranum++] = "-l";
rargs[ranum++] = loops; rargs[ranum++] = loops;
rargs[ranum++] = "-r";
rargs[ranum++] = retries;
rargs[ranum++] = "-e"; rargs[ranum++] = "-e";
rargs[ranum++] = NULL; /* will hold the read entry */ rargs[ranum++] = NULL; /* will hold the read entry */
rargs[ranum++] = NULL; rargs[ranum++] = NULL;
@ -298,6 +308,8 @@ main( int argc, char **argv )
margs[manum++] = passwd; margs[manum++] = passwd;
margs[manum++] = "-l"; margs[manum++] = "-l";
margs[manum++] = loops; margs[manum++] = loops;
margs[manum++] = "-r";
margs[manum++] = retries;
margs[manum++] = "-e"; margs[manum++] = "-e";
margs[manum++] = NULL; /* will hold the modrdn entry */ margs[manum++] = NULL; /* will hold the modrdn entry */
margs[manum++] = NULL; margs[manum++] = NULL;
@ -325,6 +337,8 @@ main( int argc, char **argv )
modargs[modanum++] = passwd; modargs[modanum++] = passwd;
modargs[modanum++] = "-l"; modargs[modanum++] = "-l";
modargs[modanum++] = loops; modargs[modanum++] = loops;
modargs[modanum++] = "-r";
modargs[modanum++] = retries;
modargs[modanum++] = "-e"; modargs[modanum++] = "-e";
modargs[modanum++] = NULL; /* will hold the modify entry */ modargs[modanum++] = NULL; /* will hold the modify entry */
modargs[modanum++] = "-a";; modargs[modanum++] = "-a";;
@ -354,6 +368,8 @@ main( int argc, char **argv )
aargs[aanum++] = passwd; aargs[aanum++] = passwd;
aargs[aanum++] = "-l"; aargs[aanum++] = "-l";
aargs[aanum++] = loops; aargs[aanum++] = loops;
aargs[aanum++] = "-r";
aargs[aanum++] = retries;
aargs[aanum++] = "-f"; aargs[aanum++] = "-f";
aargs[aanum++] = NULL; /* will hold the add data file */ aargs[aanum++] = NULL; /* will hold the add data file */
aargs[aanum++] = NULL; aargs[aanum++] = NULL;