aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--networking/nslookup.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/networking/nslookup.c b/networking/nslookup.c
index d1697f2fd..99f781e1b 100644
--- a/networking/nslookup.c
+++ b/networking/nslookup.c
@@ -263,7 +263,7 @@ struct ns {
263 263
264struct query { 264struct query {
265 const char *name; 265 const char *name;
266 unsigned qlen, rlen; 266 unsigned qlen;
267// unsigned latency; 267// unsigned latency;
268// uint8_t rcode; 268// uint8_t rcode;
269 unsigned char query[512]; 269 unsigned char query[512];
@@ -560,8 +560,9 @@ static int send_queries(struct ns *ns)
560 if (tcur - tsent >= retry_interval) { 560 if (tcur - tsent >= retry_interval) {
561 send: 561 send:
562 for (qn = 0; qn < G.query_count; qn++) { 562 for (qn = 0; qn < G.query_count; qn++) {
563 if (G.query[qn].rlen) 563 if (G.query[qn].qlen == 0)
564 continue; 564 continue; /* this one was replied already */
565
565 if (write(pfd.fd, G.query[qn].query, G.query[qn].qlen) < 0) { 566 if (write(pfd.fd, G.query[qn].query, G.query[qn].qlen) < 0) {
566 bb_perror_msg("write to '%s'", ns->name); 567 bb_perror_msg("write to '%s'", ns->name);
567 n_replies = -1; /* "no go, try next server" */ 568 n_replies = -1; /* "no go, try next server" */
@@ -614,7 +615,7 @@ static int send_queries(struct ns *ns)
614 } 615 }
615 } 616 }
616 617
617 if (G.query[qn].rlen) { 618 if (G.query[qn].qlen == 0) {
618 dbg("dropped duplicate response to query %u\n", qn); 619 dbg("dropped duplicate response to query %u\n", qn);
619 goto next; 620 goto next;
620 } 621 }
@@ -634,7 +635,7 @@ static int send_queries(struct ns *ns)
634 } 635 }
635 636
636 /* Process reply */ 637 /* Process reply */
637 G.query[qn].rlen = recvlen; 638 G.query[qn].qlen = 0; /* flag: "reply received" */
638 tcur = monotonic_ms(); 639 tcur = monotonic_ms();
639#if 1 640#if 1
640 if (option_mask32 & OPT_debug) { 641 if (option_mask32 & OPT_debug) {
@@ -733,8 +734,12 @@ static void add_query(int type, const char *dname)
733 734
734 dbg("new query#%u type %u for '%s'\n", count, type, dname); 735 dbg("new query#%u type %u for '%s'\n", count, type, dname);
735 new_q->name = dname; 736 new_q->name = dname;
736 qlen = res_mkquery(QUERY, dname, C_IN, type, NULL, 0, NULL, 737
737 new_q->query, sizeof(new_q->query)); 738 qlen = res_mkquery(QUERY, dname, C_IN, type,
739 /*data:*/ NULL, /*datalen:*/ 0,
740 /*newrr:*/ NULL,
741 new_q->query, sizeof(new_q->query)
742 );
738 new_q->qlen = qlen; 743 new_q->qlen = qlen;
739} 744}
740 745
@@ -913,13 +918,13 @@ int nslookup_main(int argc UNUSED_PARAM, char **argv)
913 918
914 err = 0; 919 err = 0;
915 for (rc = 0; rc < G.query_count; rc++) { 920 for (rc = 0; rc < G.query_count; rc++) {
916 if (G.query[rc].rlen == 0) { 921 if (G.query[rc].qlen) {
917 printf("*** Can't find %s: No answer\n", G.query[rc].name); 922 printf("*** Can't find %s: No answer\n", G.query[rc].name);
918 err = 1; 923 err = 1;
919 } 924 }
920 } 925 }
921 if (err) 926 if (err) /* should this affect exicode too? */
922 bb_putchar('\n'); /* should this affect exicode too? */ 927 bb_putchar('\n');
923 928
924 if (ENABLE_FEATURE_CLEAN_UP) { 929 if (ENABLE_FEATURE_CLEAN_UP) {
925 free(G.server); 930 free(G.server);