diff options
Diffstat (limited to 'getaddrinfo.cpp')
| -rw-r--r-- | getaddrinfo.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/getaddrinfo.cpp b/getaddrinfo.cpp index 8d9ed6d4..6bed24bc 100644 --- a/getaddrinfo.cpp +++ b/getaddrinfo.cpp @@ -65,6 +65,9 @@ #include "resolv_cache.h" #include "resolv_private.h" +#include "gethostsfile.h" +#include "hosts_cache.h" + #define ANY 0 using android::net::Experiments; @@ -1462,7 +1465,7 @@ static int dns_getaddrinfo(const char* name, const addrinfo* pai, static void _sethtent(FILE** hostf) { if (!*hostf) - *hostf = fopen(_PATH_HOSTS, "re"); + *hostf = fopen(gethostsfile(), "re"); else rewind(*hostf); } @@ -1485,7 +1488,7 @@ static struct addrinfo* _gethtent(FILE** hostf, const char* name, const struct a assert(name != NULL); assert(pai != NULL); - if (!*hostf && !(*hostf = fopen(_PATH_HOSTS, "re"))) return (NULL); + if (!*hostf && !(*hostf = fopen(gethostsfile(), "re"))) return (NULL); again: if (!(p = fgets(hostbuf, sizeof hostbuf, *hostf))) return (NULL); if (*p == '#') goto again; @@ -1549,6 +1552,13 @@ static bool files_getaddrinfo(const size_t netid, const char* name, const addrin FILE* hostf = nullptr; cur = &sentinel; + + int hc_error = hc_getaddrinfo(name, pai, &cur); + if (hc_error != EAI_SYSTEM) { + *res = sentinel.ai_next; + return sentinel.ai_next != NULL; + } + _sethtent(&hostf); while ((p = _gethtent(&hostf, name, pai)) != nullptr) { cur->ai_next = p; |
