[PATCH] Immediately try next nameserver on recv() failure

Ingo van Lil inguin at gmx.de
Wed Jul 28 12:52:08 UTC 2010


If there is a problem communicating with a nameserver the __dns_lookup()
function will not immediately advance to the next nameserver but instead
continue waiting until the timeout expires. This will cause a 30 second
delay even if no nameserver is configured in resolv.conf and no DNS is
running on localhost.

Signed-off-by: Ingo van Lil <inguin at gmx.de>
---
 libc/inet/resolv.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c
index 320aec4..80c20a2 100644
--- a/libc/inet/resolv.c
+++ b/libc/inet/resolv.c
@@ -1430,7 +1430,9 @@ int attribute_hidden __dns_lookup(const char *name,
 		packet_len = recv(fd, packet, PACKETSZ, MSG_DONTWAIT);
 #endif
 
-		if (packet_len < HFIXEDSZ) {
+		if (packet_len < 0) {
+			goto try_next_server;
+		} else if (packet_len < HFIXEDSZ) {
 			/* too short!
 			 * it's just a bogus packet from somewhere */
  bogus_packet:
-- 
1.7.1.1



More information about the uClibc mailing list