+1
−0
+9
−0
hosts_cache.cpp
0 → 100644
+523
−0
hosts_cache.h
0 → 100644
+28
−0
+7
−0
Loading
Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more
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: I5926493864d4b1291ae83f8b601bf5dcc54085cd