Author: nhosoi
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd/tools/rsearch
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv29423
Modified Files:
rsearch.c rsearch.h searchthread.c
Log Message:
Resolves: #250347
Summary: rsearch - make search timeout a configurable parameter
Description: Introduced a new option "-o <search time limit>"
Index: rsearch.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/tools/rsearch/rsearch.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- rsearch.c 10 Nov 2006 23:45:51 -0000 1.3
+++ rsearch.c 1 Aug 2007 17:51:10 -0000 1.4
@@ -96,6 +96,7 @@
"-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 *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 @@
}
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 @@
case 'n':
numeric = atoi(optarg);
break;
+ case 'o':
+ searchTimelimit = atoi(optarg);
+ break;
case 't':
threadCount = atoi(optarg);
break;
@@ -447,11 +452,12 @@
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++)
Index: rsearch.h
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/tools/rsearch/rsearch.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- rsearch.h 10 Nov 2006 23:45:51 -0000 1.3
+++ rsearch.h 1 Aug 2007 17:51:10 -0000 1.4
@@ -52,6 +52,7 @@
extern char *hostname;
extern int port;
extern int numeric;
+extern int searchTimelimit;
/**/ extern int threadCount;
/**/ extern int verbose;
/**/ extern int logging;
Index: searchthread.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/tools/rsearch/searchthread.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- searchthread.c 10 Nov 2006 23:45:51 -0000 1.4
+++ searchthread.c 1 Aug 2007 17:51:10 -0000 1.5
@@ -285,6 +285,7 @@
char filterBuffer[100];
char *pFilter;
struct timeval timeout;
+ struct timeval *timeoutp;
int scope, attrsOnly = 0;
LDAPMessage *result;
int ret;
@@ -312,10 +313,15 @@
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);
Show replies by thread