mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-21 07:09:34 -05:00
extra 'swamp' modes: -SS start searches and read responses; -SSS start all searches, then read all responses
This commit is contained in:
parent
4fbbedcf29
commit
6ac38f9cc6
1 changed files with 155 additions and 37 deletions
|
|
@ -71,7 +71,7 @@ usage( char *name, char o )
|
||||||
"[-C] "
|
"[-C] "
|
||||||
"[-F] "
|
"[-F] "
|
||||||
"[-N] "
|
"[-N] "
|
||||||
"[-S] "
|
"[-S[S[S]]] "
|
||||||
"[-i <ignore>] "
|
"[-i <ignore>] "
|
||||||
"[-l <loops>] "
|
"[-l <loops>] "
|
||||||
"[-L <outerloops>] "
|
"[-L <outerloops>] "
|
||||||
|
|
@ -83,7 +83,10 @@ usage( char *name, char o )
|
||||||
exit( EXIT_FAILURE );
|
exit( EXIT_FAILURE );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Just send requests without reading responses */
|
/* -S: just send requests without reading responses
|
||||||
|
* -SS: send all requests asynchronous and immediately start reading responses
|
||||||
|
* -SSS: send all requests asynchronous; then read responses
|
||||||
|
*/
|
||||||
static int swamp;
|
static int swamp;
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
@ -389,7 +392,12 @@ do_search( char *uri, char *manager, struct berval *passwd,
|
||||||
int rc = LDAP_SUCCESS;
|
int rc = LDAP_SUCCESS;
|
||||||
int version = LDAP_VERSION3;
|
int version = LDAP_VERSION3;
|
||||||
char buf[ BUFSIZ ];
|
char buf[ BUFSIZ ];
|
||||||
|
int *msgids = NULL, active = 0;
|
||||||
|
|
||||||
|
/* make room for msgid */
|
||||||
|
if ( swamp > 1 ) {
|
||||||
|
msgids = (int *)calloc( sizeof(int), innerloop );
|
||||||
|
}
|
||||||
|
|
||||||
retry:;
|
retry:;
|
||||||
if ( ld == NULL ) {
|
if ( ld == NULL ) {
|
||||||
|
|
@ -440,6 +448,110 @@ retry:;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( swamp > 1 ) {
|
||||||
|
do {
|
||||||
|
LDAPMessage *res = NULL;
|
||||||
|
int j, msgid;
|
||||||
|
|
||||||
|
if ( i < innerloop ) {
|
||||||
|
rc = ldap_search_ext( ld, sbase, scope,
|
||||||
|
filter, NULL, noattrs, NULL, NULL,
|
||||||
|
NULL, LDAP_NO_LIMIT, &msgids[i] );
|
||||||
|
|
||||||
|
active++;
|
||||||
|
#if 0
|
||||||
|
fprintf( stderr,
|
||||||
|
">>> PID=%ld - Search(%d, %d, %d, %d): "
|
||||||
|
"base=\"%s\" scope=%s filter=\"%s\"\n",
|
||||||
|
(long) pid, innerloop, i, active, msgids[i],
|
||||||
|
sbase, ldap_pvt_scope2str( scope ), filter );
|
||||||
|
#endif
|
||||||
|
i++;
|
||||||
|
|
||||||
|
if ( rc ) {
|
||||||
|
int first = tester_ignore_err( rc );
|
||||||
|
/* if ignore.. */
|
||||||
|
if ( first ) {
|
||||||
|
/* only log if first occurrence */
|
||||||
|
if ( ( force < 2 && first > 0 ) || abs(first) == 1 ) {
|
||||||
|
tester_ldap_error( ld, "ldap_search_ext", NULL );
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* busy needs special handling */
|
||||||
|
snprintf( buf, sizeof( buf ),
|
||||||
|
"base=\"%s\" filter=\"%s\"\n",
|
||||||
|
sbase, filter );
|
||||||
|
tester_ldap_error( ld, "ldap_search_ext", buf );
|
||||||
|
if ( rc == LDAP_BUSY && do_retry > 0 ) {
|
||||||
|
ldap_unbind_ext( ld, NULL, NULL );
|
||||||
|
ld = NULL;
|
||||||
|
do_retry--;
|
||||||
|
goto retry;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( swamp > 2 ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rc = ldap_result( ld, LDAP_RES_ANY, 0, NULL, &res );
|
||||||
|
switch ( rc ) {
|
||||||
|
case -1:
|
||||||
|
/* gone really bad */
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
case 0:
|
||||||
|
/* timeout (impossible) */
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LDAP_RES_SEARCH_ENTRY:
|
||||||
|
case LDAP_RES_SEARCH_REFERENCE:
|
||||||
|
/* ignore */
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LDAP_RES_SEARCH_RESULT:
|
||||||
|
/* just remove, no error checking (TODO?) */
|
||||||
|
msgid = ldap_msgid( res );
|
||||||
|
|
||||||
|
/* linear search, bah */
|
||||||
|
for ( j = 0; j < i; j++ ) {
|
||||||
|
if ( msgids[ j ] == msgid ) {
|
||||||
|
msgids[ j ] = -1;
|
||||||
|
active--;
|
||||||
|
#if 0
|
||||||
|
fprintf( stderr,
|
||||||
|
"<<< PID=%ld - SearchDone(%d, %d, %d, %d): "
|
||||||
|
"base=\"%s\" scope=%s filter=\"%s\"\n",
|
||||||
|
(long) pid, innerloop, j, active, msgid,
|
||||||
|
sbase, ldap_pvt_scope2str( scope ), filter );
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
/* other messages unexpected */
|
||||||
|
fprintf( stderr,
|
||||||
|
"### PID=%ld - Search(%d): "
|
||||||
|
"base=\"%s\" scope=%s filter=\"%s\" "
|
||||||
|
"attrs=%s%s. unexpected response tag=%d\n",
|
||||||
|
(long) pid, innerloop,
|
||||||
|
sbase, ldap_pvt_scope2str( scope ), filter,
|
||||||
|
attrs[0], attrs[1] ? " (more...)" : "", rc );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( res != NULL ) {
|
||||||
|
ldap_msgfree( res );
|
||||||
|
}
|
||||||
|
} while ( i < innerloop || active > 0 );
|
||||||
|
|
||||||
|
} else {
|
||||||
for ( ; i < innerloop; i++ ) {
|
for ( ; i < innerloop; i++ ) {
|
||||||
LDAPMessage *res = NULL;
|
LDAPMessage *res = NULL;
|
||||||
|
|
||||||
|
|
@ -484,6 +596,12 @@ retry:;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanup:;
|
||||||
|
if ( msgids != NULL ) {
|
||||||
|
free( msgids );
|
||||||
|
}
|
||||||
|
|
||||||
if ( ldp != NULL ) {
|
if ( ldp != NULL ) {
|
||||||
*ldp = ld;
|
*ldp = ld;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue