From ec22f7dffc14e04fdceee6567713648be8078d39 Mon Sep 17 00:00:00 2001 From: Rusty Bird Date: Wed, 11 Jan 2017 14:46:37 +0000 Subject: [bionic] Add net.dnscache property, like BIONIC_DNSCACHE env variable --- libc/dns/resolv/res_cache.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libc/dns/resolv/res_cache.c b/libc/dns/resolv/res_cache.c index ad2c5c0..d8586f5 100644 --- a/libc/dns/resolv/res_cache.c +++ b/libc/dns/resolv/res_cache.c @@ -99,11 +99,12 @@ * is too short to accomodate the cached result. */ -/* the name of an environment variable that will be checked the first time - * this code is called if its value is "0", then the resolver cache is - * disabled. +/* the name of an environment variable and a property that will be checked + * whenever the cache is (re)initialized. If either value is "0", then the + * resolver cache is disabled. */ #define CONFIG_ENV "BIONIC_DNSCACHE" +#define CONFIG_PROP "net.dnscache" /* default number of entries kept in the cache. This value has been * determined by browsing through various sites and counting the number @@ -1815,8 +1816,10 @@ static void _res_cache_init(void) { const char* env = getenv(CONFIG_ENV); + char prop[PROP_VALUE_MAX]; - if (env && atoi(env) == 0) { + if ((env && atoi(env) == 0) || + (__system_property_get(CONFIG_PROP, prop) && atoi(prop) == 0)) { /* the cache is disabled */ return; } -- 2.1.4