diff --git a/libc/dns/include/resolv_netid.h b/libc/dns/include/resolv_netid.h index f1b88920e..e5521b809 100644 --- a/libc/dns/include/resolv_netid.h +++ b/libc/dns/include/resolv_netid.h @@ -61,6 +61,9 @@ int android_getaddrinfofornet(const char *, const char *, const struct addrinfo extern void _resolv_set_nameservers_for_net(unsigned netid, const char** servers, int numservers, const char *domains) __used_in_netd; +/* flush the cache associated with a certain network */ +extern void _resolv_flush_cache_for_net(unsigned netid) __used_in_netd; + /* delete the cache associated with a certain network */ extern void _resolv_delete_cache_for_net(unsigned netid) __used_in_netd; diff --git a/libc/dns/resolv/res_cache.c b/libc/dns/resolv/res_cache.c index c934b4ee6..419b748d4 100644 --- a/libc/dns/resolv/res_cache.c +++ b/libc/dns/resolv/res_cache.c @@ -1831,6 +1831,17 @@ _get_res_cache_for_net_locked(unsigned netid) return cache; } +void +_resolv_flush_cache_for_net(unsigned netid) +{ + pthread_once(&_res_cache_once, _res_cache_init); + pthread_mutex_lock(&_res_cache_list_lock); + + _flush_cache_for_net_locked(netid); + + pthread_mutex_unlock(&_res_cache_list_lock); +} + static void _flush_cache_for_net_locked(unsigned netid) {