Hi, Ed. Which version of uclibc you are using? I've spent a lot of time in that particular case with getaddrinfo(), and as of 0.9.32 it behaves correctly. Make sure that this problem is really related to resolving (try plain old sectioned printf debugging :) ).
Also try the attached patch to see if it helps. On Mon, 2012-04-16 at 15:05 +0100, Ed W wrote: > Hi, I'm suffering extreme performance problems with getaddrinfo being > used by ipset to do conversions from IP textual strings to number. > Although the IP address is textual there is a reverse DNS lookup > performed and in the event that my resolver is slow, this is sometimes > taking 60seconds or so to return > > (specifics are the box has multiple internet connections, if one > connection is dead we need ipset to force use of another connection, but > ipset does a reverse lookup down the dead connection which seems to take > lots of multi-sec timeout) > > Is anyone sitting on a patch to optimise getaddrinfo for the situation > of hint = AI_NUMERICHOST ? Otherwise I will investigate, but would > appreciate a helping hand from someone more familiar with the code? > Willing to pay for a fix? > > Many thanks > > Ed W > _______________________________________________ > uClibc mailing list > [email protected] > http://lists.busybox.net/mailman/listinfo/uclibc -- Best wishes, Alexander Komyagin
>From 7208ecbcccbafce2a659dcd2d12659519906eba4 Mon Sep 17 00:00:00 2001 From: Alexander Komyagin <[email protected]> Date: Wed, 4 Apr 2012 12:58:37 +0400 Subject: [PATCH] getaddrinfo(): avoid call to __check_pf() when not needed __check_pf() function is called from getaddrinfo() and it calls getifaddrs(), which is too much overhead especially if RSBAC-Net is enabled. So with this patch __check_pf() is being called only when AI_ADDRCONFIG hint flag is specified - just when we really need that check. Signed-off-by: Alexander Komyagin <[email protected]> --- libc/inet/getaddrinfo.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-) diff --git a/libc/inet/getaddrinfo.c b/libc/inet/getaddrinfo.c index e7511f6..4f9d0cd 100644 --- a/libc/inet/getaddrinfo.c +++ b/libc/inet/getaddrinfo.c @@ -401,7 +401,14 @@ gaih_inet(const char *name, const struct gaih_service *service, int rc; int v4mapped = (req->ai_family == PF_UNSPEC || req->ai_family == PF_INET6) && (req->ai_flags & AI_V4MAPPED); - unsigned seen = __check_pf(); + + //"seen" variable won't be used if AI_ADDRCONFIG is + // not specified. So avoid unnecessary call to __check_pf() + // since it can be costly esp. when RSBAC-Net is enabled. + unsigned seen = 0; + if (req->ai_flags & AI_ADDRCONFIG) { + seen = __check_pf(); + } memset(&nullserv, 0, sizeof(nullserv)); -- 1.7.1
_______________________________________________ uClibc mailing list [email protected] http://lists.busybox.net/mailman/listinfo/uclibc
