From 52764f5546362d0ffab99afaffe8e8c7f21f8ef2 Mon Sep 17 00:00:00 2001 From: Robert Greenwalt Date: Wed, 25 Jan 2012 15:16:03 -0800 Subject: [PATCH] Increase the size of the system-wide dns cache 32 enteries perhaps was ok for per-process caching with ipv4 only but adding ipv6 records makes it effectively 16 entries and making it system wide makes is pretty useless. Increasing to 640 entries. bug:5841178 Change-Id: I879f8bf4d3c4d8c1708bb46d46a67c1f64b1861f --- libc/netbsd/resolv/res_cache.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/libc/netbsd/resolv/res_cache.c b/libc/netbsd/resolv/res_cache.c index 24edbb661..9ae627ca4 100644 --- a/libc/netbsd/resolv/res_cache.c +++ b/libc/netbsd/resolv/res_cache.c @@ -138,9 +138,19 @@ * * The system property ro.net.dns_cache_size can be used to override the default * value with a custom value + * + * + * ****************************************** + * * NOTE - this has changed. + * * 1) we've added IPv6 support so each dns query results in 2 responses + * * 2) we've made this a system-wide cache, so the cost is less (it's not + * * duplicated in each process) and the need is greater (more processes + * * making different requests). + * * Upping by 2x for IPv6 + * * Upping by another 5x for the centralized nature + * ***************************************** */ -#define CONFIG_MAX_ENTRIES 64 - +#define CONFIG_MAX_ENTRIES 64 * 2 * 5 /* name of the system property that can be used to set the cache size */ #define DNS_CACHE_SIZE_PROP_NAME "ro.net.dns_cache_size" @@ -1218,6 +1228,16 @@ _res_cache_get_max_entries( void ) int result = -1; char cache_size[PROP_VALUE_MAX]; + const char* cache_mode = getenv("ANDROID_DNS_MODE"); + + if (cache_mode == NULL || strcmp(cache_mode, "local") != 0) { + // Don't use the cache in local mode. This is used by the + // proxy itself. + // TODO - change this to 0 when all dns stuff uses proxy (5918973) + XLOG("setup cache for non-cache process. size=1"); + return 1; + } + if (__system_property_get(DNS_CACHE_SIZE_PROP_NAME, cache_size) > 0) { result = atoi(cache_size); }