If I get an initial "Name or service not known" (EAI_NONAME), the next call to getaddrinfo() seems to go straight to the dns instead of checking the cache first (nscd logs show no lookup attempts, tcpdump shows traffic to DNS server). If the first call succeeds in getting an address, from then on, all getaddrinfo() calls go to nscd first, as expected.
I'm compiling against glibc-2.13 for arm linux. In my rc.d, nscd is started before my daemon. nscd is set to disallow shared caches, and maintain a host cache. I am using the nscd from busybox (0.47). nsswitch.conf is set so host checks cache/files/dns. hosts.conf is set to check files/bind.
My daemon is calling getaddrinfo().
I have debug logs for nscd running, and they show that the client started to read the DNS response closes with a "Broken Pipe" error.
After that it will show GAI attempts from other daemons attempting to use the cache (so I know it's not nscd locked up or anything), but the daemon that got EAI_NONAME never again contacts nscd to do a cache lookup.
If I restart the daemon, I get the same behaviour, if the first DNS query times out again.
Is there something in glibc that is invalidating my daemon's link to the cache? Is there a way to reconnect my daemon to the cache without restarting it (similar to forcing a resolv.conf re-load via res_init())?
getaddrinfo()
"really" often. Let's say 100++ times? Try it and monitor access tonscd
. I can not test this here, but there might be a chance your daemon decides to test thenscd
connection then again and if succesful uses it from then on. – Natalienatalinanscd
, do you? – Natalienatalina