__dns_lookup() timeout
Clem Taylor
clem.taylor at gmail.com
Thu Jan 18 17:02:55 PST 2007
I recently ran into a problem that a call to gethostbyname() in the
startup scripts was tripping a watchdog timeout every time the system
booted up. It turns out that DNS was configured to point to a bogus
server. It was taking about 20-30 seconds to make it through a
gethostbyname(). This seems like a really long time to wait for name
resolv.
libc/inet/resolv.c specifies a 10 second (REPLY_TIMEOUT) timeout with
3 (MAX_RETRIES). The worst case timeout time seems to be about 10
(REPLY_TIMEOUT) * 3 (MAX_RETRIES) * 3 (MAX_SERVERS) or 1.5 minutes.
With the stuff I normally work on, 100ms is a long time, so 90 seconds
is a lifetime...
I'm going to patch my uclibc to use a shorter timeout, but I don't
have a feel for how long it can take to resolve a name on the typical
DNS server. I was wondering if anyone has a recommendation on how
short I can get before I'd start to fail to resolv in the typical
case.
I ran 'time dig <random hopefully non-locally cached website>' and the
slowest query was 316ms with most taking ~35ms.
I was thinking of setting REPLY_TIMEOUT to 1 and MAX_RETRIES to 4, so
for a typical single DNS server configuration, gethostbyname() would
timeout in 4 seconds.
Does this seem like too short a timeout?
--Clem
More information about the uClibc
mailing list