Revert most of "Cleanup: Delete dead code."
This reverts most of commit 2582f02a01cd56c56a4e6c9de4444a6ec937cc37.
The DNS cache flushing code needs to be called when routes change.
Change-Id: I5b04121bc428cc6a2e136b6c3269c395bfb4981f
bug:16549455
diff --git a/libc/dns/include/resolv_netid.h b/libc/dns/include/resolv_netid.h
index f1b8892..e5521b8 100644
--- a/libc/dns/include/resolv_netid.h
+++ b/libc/dns/include/resolv_netid.h
@@ -61,6 +61,9 @@
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 c934b4e..419b748 100644
--- a/libc/dns/resolv/res_cache.c
+++ b/libc/dns/resolv/res_cache.c
@@ -1831,6 +1831,17 @@
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)
{