netd: Sort and cache hosts file data for fast lookup
The hosts file is normally searched linearly. This is very slow when the file is large. To mitigate this, read the hosts file and sort the entries in an in-memory cache. When an address is requested via gethostbyname or getaddrinfo, binary search the cache. In case where the cache is not available, return a suitable error code and fall back to the existing lookup code. This has been written to behave as much like the existing lookup code as possible. But note bionic and glibc differ in behavior for some corner cases. Choose the most standard compliant behavior for these where possible. Otherwise choose the behavior that seems most reasonable. Note: this change is the analogue of the bionic change of the same name. Both should be kept in sync. Change-Id: If0a63de79508c63ebc6846dcc093e70f3b9f655a
Loading
Please register or sign in to comment