https://fedorahosted.org/sssd/ticket/811
Much of the patch is a conversion from system "struct hostent" to our
own "struct resolv_hostent".
After some going back and forth, the addresses are stored pretty much
same as in "struct hostent" in a uint8_t buffer. The reason being
simpler access to the address as seen in the inet_ntop calls without
having to explicitly specify v6 or v4 component of a union, for example.
The "family" structure member specifies the address family which implies
the address type after all.
For resolving hostnames from /etc/hosts, I still used
ares_gethostbyname() with databases set to "files" only. It is
convenient do to so, as they implement the parser and provide a nice
interface. The only issue I came across was that if a hostname is not
found in /etc/hosts, c-ares would return ARES_ECONNREFUSED. I consider
this a c-ares bug and will handle this upstream.
Nack,
I have some comments and suggestions. Please note that line numbers are taken
from the patched file.
<nitpicking>
440, 483, 531 - return NULL should be enough, no need to jump
</nitpicking>
504 - the ->ipaddr missing?
615 - condition doesn't make any sense
617 - missing attribute
840 - throw this block out? IMO it's redundant
857 - I'd much rather see != instead of <
926 - maybe one line comment about what does the block do or under what
circumstances can it be invoked?
933 - I'd move this above the previous block and in the block add the timeout
again (similar situation is around line 847s in case the block on line 840s
will stay). In current state of the code, the timeout would be shared by two
queries in case the first one is interrupted.
971 - I'd merge functions resolv_gethostbyname_dns_done and
resolv_gethostbyname_next_dns_done, they are almost identical
Jan