diff options
author | Noriko Hosoi <nhosoi@redhat.com> | 2007-08-01 17:51:10 +0000 |
---|---|---|
committer | Noriko Hosoi <nhosoi@redhat.com> | 2007-08-01 17:51:10 +0000 |
commit | 2ebeaf1fbbba60e8ed0040bb904c1bb858a876c3 (patch) | |
tree | 2bfa0afeabdbf7e9ba1b60e80fc2b28dc0a5c33d | |
parent | 4fe857b24306d1cebc1096b68c9ff46dfda5cbe4 (diff) | |
download | ds-2ebeaf1fbbba60e8ed0040bb904c1bb858a876c3.tar.gz ds-2ebeaf1fbbba60e8ed0040bb904c1bb858a876c3.tar.xz ds-2ebeaf1fbbba60e8ed0040bb904c1bb858a876c3.zip |
Resolves: #250347
Summary: rsearch - make search timeout a configurable parameter
Description: Introduced a new option "-o <search time limit>"
-rw-r--r-- | ldap/servers/slapd/tools/rsearch/rsearch.c | 10 | ||||
-rw-r--r-- | ldap/servers/slapd/tools/rsearch/rsearch.h | 1 | ||||
-rw-r--r-- | ldap/servers/slapd/tools/rsearch/searchthread.c | 12 |
3 files changed, 18 insertions, 5 deletions
diff --git a/ldap/servers/slapd/tools/rsearch/rsearch.c b/ldap/servers/slapd/tools/rsearch/rsearch.c index 17e998d2..313eed3d 100644 --- a/ldap/servers/slapd/tools/rsearch/rsearch.c +++ b/ldap/servers/slapd/tools/rsearch/rsearch.c @@ -96,6 +96,7 @@ void usage() "-a file -- list of attributes for search request in a file\n" " -- (use '-a \\?' to see the format ; -a & -A are mutually exclusive)\n" "-n number -- (reserved for future use)\n" + "-o number -- Search time limit, in seconds; (default: 30; no time limit: 0)\n" "-j number -- sample interval, in seconds (default: %u)\n" "-t number -- threads (default: %d)\n" "-T number -- Time limit, in seconds; cmd stops when exceeds <number>\n" @@ -202,6 +203,7 @@ char **string_to_list(char* s) char *hostname = DEFAULT_HOSTNAME; int port = DEFAULT_PORT; int numeric = 0; +int searchTimelimit = 30; int threadCount = DEFAULT_THREADS; int verbose = 0; int logging = 0; @@ -251,7 +253,7 @@ int main(int argc, char** argv) } while ((ch = getopt(argc, argv, - "B:a:j:i:h:s:f:p:t:T:D:w:n:A:S:C:R:bvlyqmMcduNLHx?V")) + "B:a:j:i:h:s:f:p:o:t:T:D:w:n:A:S:C:R:bvlyqmMcduNLHx?V")) != EOF) switch (ch) { case 'h': @@ -308,6 +310,9 @@ int main(int argc, char** argv) case 'n': numeric = atoi(optarg); break; + case 'o': + searchTimelimit = atoi(optarg); + break; case 't': threadCount = atoi(optarg); break; @@ -447,11 +452,12 @@ int main(int argc, char** argv) for (x = 0; x < numThreads; x++) { alive = st_alive(threads[x]); if (alive < 1) { + int limit = -1 * (searchTimelimit>timeLimit?searchTimelimit:timeLimit + 40) * 1000 / sampleInterval; int y; PRThread *tid; printf("T%d no heartbeat", st_getThread(threads[x], &tid)); - if (alive <= -4) { + if (alive <= limit) { printf(" -- Dead thread being reaped.\n"); PR_JoinThread(tid); for (y = x+1; y < numThreads; y++) diff --git a/ldap/servers/slapd/tools/rsearch/rsearch.h b/ldap/servers/slapd/tools/rsearch/rsearch.h index 3f797cc0..d62c80d8 100644 --- a/ldap/servers/slapd/tools/rsearch/rsearch.h +++ b/ldap/servers/slapd/tools/rsearch/rsearch.h @@ -52,6 +52,7 @@ typedef enum { op_search, op_modify, op_idxmodify, op_add, op_delete, op_compare extern char *hostname; extern int port; extern int numeric; +extern int searchTimelimit; /**/ extern int threadCount; /**/ extern int verbose; /**/ extern int logging; diff --git a/ldap/servers/slapd/tools/rsearch/searchthread.c b/ldap/servers/slapd/tools/rsearch/searchthread.c index cfb16b52..48430439 100644 --- a/ldap/servers/slapd/tools/rsearch/searchthread.c +++ b/ldap/servers/slapd/tools/rsearch/searchthread.c @@ -285,6 +285,7 @@ static int st_search(SearchThread *st) char filterBuffer[100]; char *pFilter; struct timeval timeout; + struct timeval *timeoutp; int scope, attrsOnly = 0; LDAPMessage *result; int ret; @@ -312,10 +313,15 @@ static int st_search(SearchThread *st) if (!attrToReturn) attrToReturn = nt_get_all(attrTable); - timeout.tv_sec = 30; - timeout.tv_usec = 0; + if (searchTimelimit <= 0) { + timeoutp = NULL; + } else { + timeout.tv_sec = searchTimelimit; + timeout.tv_usec = 0; + timeoutp = &timeout; + } ret = ldap_search_st(st->ld, suffix, scope, pFilter, attrToReturn, - attrsOnly, &timeout, &result); + attrsOnly, timeoutp, &result); if (ret != LDAP_SUCCESS) { fprintf(stderr, "T%d: failed to search 2, error=0x%02X\n", st->id, ret); |