summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2004-01-24 08:33:39 +0000
committerEric Andersen <andersen@codepoet.org>2004-01-24 08:33:39 +0000
commit48cfeab44c6463ab193b0efd7b61837140985dd5 (patch)
tree893dae5253fc35311ee9096c4257662dc77dfc12
parent0a9703a22003033a17acdf73287db708f31f50da (diff)
Imre Sunyi writes:
Hi Erik I have corrected a bug in uClibc/libc/inet/resolv.c in function __dns_lookup(). Have attaced a txt file with my diffs regarding to uClibc 0.9.26. If two nameservers are included in /etc/resolv.conf and the first one is wrong and the secondary is correct the algorithm never looked up the secondary one. Please review my diff and feel free to submit the patch onto your CVS. If reading manual page resolv.conf(5) under nameserver and how the algorithm should work the previous dns_lookup did not fully followed that. Regards Imre Sunyi
-rw-r--r--libc/inet/resolv.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c
index f3a770f31..592582133 100644
--- a/libc/inet/resolv.c
+++ b/libc/inet/resolv.c
@@ -687,7 +687,7 @@ int __dns_lookup(const char *name, int type, int nscount, char **nsip,
ns %= nscount;
UNLOCK;
- while (retries++ < MAX_RETRIES) {
+ while (retries < MAX_RETRIES) {
if (fd != -1)
close(fd);
@@ -732,7 +732,7 @@ int __dns_lookup(const char *name, int type, int nscount, char **nsip,
len = i + j;
DPRINTF("On try %d, sending query to port %d of machine %s\n",
- retries, NAMESERVER_PORT, dns);
+ retries+1, NAMESERVER_PORT, dns);
#ifdef __UCLIBC_HAS_IPV6__
v6 = inet_pton(AF_INET6, dns, &sa6.sin6_addr) > 0;
@@ -741,6 +741,7 @@ int __dns_lookup(const char *name, int type, int nscount, char **nsip,
fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
#endif
if (fd < 0) {
+ retries++;
continue;
}
@@ -766,6 +767,7 @@ int __dns_lookup(const char *name, int type, int nscount, char **nsip,
goto tryall;
} else
/* retry */
+ retries++;
continue;
}
@@ -783,7 +785,7 @@ int __dns_lookup(const char *name, int type, int nscount, char **nsip,
/* timed out, so retry send and receive,
* to next nameserver on queue */
- goto again;
+ goto tryall;
}
i = recv(fd, packet, 512, 0);
@@ -861,14 +863,14 @@ int __dns_lookup(const char *name, int type, int nscount, char **nsip,
/* if there are other nameservers, give them a go,
otherwise return with error */
{
- int sdomains;
-
- BIGLOCK;
- sdomains=__searchdomains;
- BIGUNLOCK;
variant = 0;
- if (retries >= nscount*(sdomains+1))
- goto fail;
+ LOCK;
+ ns = (ns + 1) % nscount;
+ if (ns == 0)
+ retries++;
+
+ UNLOCK;
+ continue;
}
again:
@@ -879,13 +881,16 @@ int __dns_lookup(const char *name, int type, int nscount, char **nsip,
sdomains=__searchdomains;
BIGUNLOCK;
- if (variant < sdomains) {
+ if (variant < ((sdomains - 1) && strchr(lookup, '.') == NULL)) {
/* next search */
variant++;
} else {
/* next server, first search */
LOCK;
ns = (ns + 1) % nscount;
+ if (ns == 0)
+ retries++;
+
UNLOCK;
variant = 0;
}