summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorian <ian>2000-09-16 19:29:22 +0000
committerian <ian>2000-09-16 19:29:22 +0000
commit295cf5254de011800b43c6d39eab278a48ba917f (patch)
treee413afbeeea332c411ea28c0e4f4c6988c620dcd /client
parentb8b163f96bb47de6c63ebe0770d8e831fcf036f7 (diff)
+ * Improvements to adnslogres (incl. new -c option) from Tony Finch.
@@ -6,6 +6,7 @@ General Improvements: * adnshost has --config option for overriding configuration. + * Improvements to adnslogres (incl. new -c option) from Tony Finch. * Regression tests now include `adnshost' invocations. * Test cancellation both before and after query completion. @@ -25,7 +26,6 @@ * Kill bogus warning, adh-main.c: `arg2' might be used uninitialized ... * Add extra {...} near adnslogres.c:167 to kill spurious warning. * Use `printf' instead of `echo -n'. - --
Diffstat (limited to 'client')
-rw-r--r--client/adnslogres.c62
1 files changed, 35 insertions, 27 deletions
diff --git a/client/adnslogres.c b/client/adnslogres.c
index b8e5f52..cb0bc27 100644
--- a/client/adnslogres.c
+++ b/client/adnslogres.c
@@ -48,7 +48,8 @@ static const char * const cvsid =
#include "adns.h"
/* maximum number of concurrent DNS queries */
-#define MAXPENDING 1000
+#define MAXMAXPENDING 64000
+#define DEFMAXPENDING 2000
/* maximum length of a line */
#define MAXLINE 1024
@@ -157,7 +158,7 @@ static logline *readline(FILE *inf, adns_state adns, int opts) {
return NULL;
}
-static void proclog(FILE *inf, FILE *outf, int opts) {
+static void proclog(FILE *inf, FILE *outf, int maxpending, int opts) {
int eof, err, len;
adns_state adns;
adns_answer *answer;
@@ -168,18 +169,19 @@ static void proclog(FILE *inf, FILE *outf, int opts) {
head= tail= readline(inf, adns, opts);
len= 1; eof= 0;
while (head) {
- if (opts & OPT_DEBUG)
- msg("%d in queue; checking %.*s", len,
- head->rest-head->addr, guard_null(head->addr));
- if (eof || len > MAXPENDING) {
- if (opts & OPT_POLL)
- err= adns_wait_poll(adns, &head->query, &answer, NULL);
- else
- err= adns_wait(adns, &head->query, &answer, NULL);
- } else {
- err= adns_check(adns, &head->query, &answer, NULL);
- }
- if (err != EAGAIN) {
+ while (head) {
+ if (opts & OPT_DEBUG)
+ msg("%d in queue; checking %.*s", len,
+ head->rest-head->addr, guard_null(head->addr));
+ if (eof || len > maxpending) {
+ if (opts & OPT_POLL)
+ err= adns_wait_poll(adns, &head->query, &answer, NULL);
+ else
+ err= adns_wait(adns, &head->query, &answer, NULL);
+ } else {
+ err= adns_check(adns, &head->query, &answer, NULL);
+ }
+ if (err == EAGAIN) break;
printline(outf, head->start, head->addr, head->rest,
answer->status == adns_s_ok ? *answer->rrs.str : NULL);
line= head; head= head->next;
@@ -188,15 +190,12 @@ static void proclog(FILE *inf, FILE *outf, int opts) {
}
if (!eof) {
line= readline(inf, adns, opts);
- if (!line)
+ if (line) {
+ if (!head) head= line;
+ else tail->next= line;
+ tail= line; len++;
+ } else {
eof= 1;
- else {
- if (!head)
- head= line;
- else
- tail->next= line;
- tail= line;
- len++;
}
}
}
@@ -204,12 +203,13 @@ static void proclog(FILE *inf, FILE *outf, int opts) {
}
static void usage(void) {
- fprintf(stderr, "usage: %s [-d] [-p] [logfile]\n", progname);
+ fprintf(stderr, "usage: %s [-d] [-p] [-c concurrency] [logfile]\n", progname);
exit(1);
}
int main(int argc, char *argv[]) {
- int c, opts;
+ int c, opts, maxpending;
+ extern char *optarg;
FILE *inf;
progname= strrchr(*argv, '/');
@@ -217,10 +217,18 @@ int main(int argc, char *argv[]) {
progname++;
else
progname= *argv;
- opts= 0;
- while ((c= getopt(argc, argv, "dp")) != -1)
+ maxpending= DEFMAXPENDING;
+ opts= 0;
+ while ((c= getopt(argc, argv, "c:dp")) != -1)
switch (c) {
+ case 'c':
+ maxpending= atoi(optarg);
+ if (maxpending < 1 || maxpending > MAXMAXPENDING) {
+ fprintf(stderr, "%s: unfeasible concurrency %d\n", progname, maxpending);
+ exit(1);
+ }
+ break;
case 'd':
opts|= OPT_DEBUG;
break;
@@ -245,7 +253,7 @@ int main(int argc, char *argv[]) {
if (!inf)
aargh("couldn't open input");
- proclog(inf, stdout, opts);
+ proclog(inf, stdout, maxpending, opts);
if (fclose(inf))
aargh("fclose input");