Actually I have static name server addresses in files of hosts and resolv.conf managed by system administrators, but those "static" addresses may alter vary at times, 3 months, 5 months and the like, without any regularity, and I'm not able to learn the changes in time. So it may be inconvenient for set up the resolver directive. However, it's acceptable. :)
Generally speaking, getaddrinfo_a's non-portability does matter. But my platform is specific. It seems not a concern to me.
I'm not sure about the implementation of getaddrinfo_a either, also guessing it making use of signals or threads. I wanna probe into it.
agentzh, you do persuade me to enjoy patching support for hosts and resolv.conf.
On Wednesday, July 10, 2013 1:05:41 PM UTC+8, agentzh wrote:
Hello!
On Tue, Jul 9, 2013 at 8:02 PM, Glen Cao wrote:
> I'd had headache about setpeername() and connect() receiving domain names as
> the first argument (actually 2nd), before Chaos suggested local DNS relay
> and you suggested lua-resty-dns.
>
Why not just configure the "resolver" directive in your nginx.conf?
> I've thought about using async name resolving such as getaddrinfo_a from
> glibc, but Chaos reminded me of the like efficiency issue.
>
No, getaddrinfo_a sucks in that it uses pthreads internally AFAIK
which is still blocking OS threads per se, AFAIK. Not to mention it is
not portable.
> I also thought about making Nginx core supporting /etc/resolve.conf, but
> that might lead to an alone branch and become an obstacle in updating Nginx.
>
I believe the Nginx team is quite open to accepting such patches. Feel
free to submit your patches to the nginx-devel mailing list. Maxim
Dounin et al. should hold your hands there ;) So you probably don't
really have to maintain a branch in the long term. (Actually I've been
planning to write such patches myself but haven't got the time.)
Best regards,
-agentzh