diff options
author | green <green@FreeBSD.org> | 2004-02-21 22:42:54 +0000 |
---|---|---|
committer | green <green@FreeBSD.org> | 2004-02-21 22:42:54 +0000 |
commit | 458859b90829261eff3df246a6f9f8e93d569106 (patch) | |
tree | 74bf8e80507de885293cbd9c69742669632902a6 /tools/regression/gaithrstress | |
parent | 588863d371a3553d8888a2c2e24504aa72ce63dc (diff) | |
download | FreeBSD-src-458859b90829261eff3df246a6f9f8e93d569106.zip FreeBSD-src-458859b90829261eff3df246a6f9f8e93d569106.tar.gz |
Add some more comments and a -4 argument to restrict searches to only
A (not default A and AAAA) records. Now the longest time that a -4
thread might hang trying to resolve is only 2:30 instead of 5:00 ;)
Diffstat (limited to 'tools/regression/gaithrstress')
-rw-r--r-- | tools/regression/gaithrstress/gaithrstress.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/tools/regression/gaithrstress/gaithrstress.c b/tools/regression/gaithrstress/gaithrstress.c index 2108f98..023e0b5 100644 --- a/tools/regression/gaithrstress/gaithrstress.c +++ b/tools/regression/gaithrstress/gaithrstress.c @@ -53,6 +53,7 @@ static volatile int workers_stop = 0; static double max_random_sleep = 1.0; static char **randwords; static size_t nrandwords; +static const struct addrinfo *hints, hintipv4only = { .ai_family = AF_INET }; /* * We don't have good random(3)-type functions that are thread-safe, @@ -89,13 +90,20 @@ randomsleep(double max_sleep_sec) * Start looking up arbitrary hostnames and record the successes/failures. * Between lookups, sleep a random amount of time to make sure threads * stay well out of synchronization. + * + * Host name: part probability + * ---- ----------- + * www. 1/2 + * random word always, equal + * random word 1/3, equal + * .(net|com|org) equal */ static void * work(void *arg) { struct worker *w = arg; - /* Turn off domain name list searching. */ + /* Turn off domain name list searching as much as possible. */ if (_res.options & RES_INIT || res_init() == 0) _res.options &= ~RES_DNSRCH; do { @@ -115,7 +123,7 @@ work(void *arg) suffixes[my_arc4random_r() % nsuffixes]) == -1) continue; (void)clock_gettime(CLOCK_REALTIME, &ts_begintime); - error = getaddrinfo(hostname, NULL, NULL, &res); + error = getaddrinfo(hostname, NULL, hints, &res); (void)clock_gettime(CLOCK_REALTIME, &ts_total); ts_total.tv_sec -= ts_begintime.tv_sec; ts_total.tv_nsec -= ts_begintime.tv_nsec; @@ -188,8 +196,11 @@ main(int argc, char **argv) { printf("%s: threaded stress-tester for getaddrinfo(3)\n", getprogname()); printf("(c) 2004 Brian Feldman <green@FreeBSD.org>\n"); - while ((ch = getopt(argc, argv, "s:t:w:")) != -1) { + while ((ch = getopt(argc, argv, "4s:t:w:")) != -1) { switch (ch) { + case '4': + hints = &hintipv4only; + break; case 's': max_random_sleep = strtod(optarg, &send); if (*send != '\0') @@ -205,8 +216,8 @@ main(int argc, char **argv) { break; default: usage: - fprintf(stderr, "usage: %s [-s sleep] [-t threads] " - "[-w wordfile]\n", getprogname()); + fprintf(stderr, "usage: %s [-4] [-s sleep] " + "[-t threads] [-w wordfile]\n", getprogname()); exit(2); } } |