From: Wouter Wijngaards Date: Tue, 17 Jul 2018 14:42:38 +0000 (+0000) Subject: - Resize ratelimit and ip-ratelimit caches if changed on reload. X-Git-Tag: release-1.8.0rc1~95 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=75792169226c44c688cc4f94a2043b6c2fc5fef2;p=thirdparty%2Funbound.git - Resize ratelimit and ip-ratelimit caches if changed on reload. git-svn-id: file:///svn/unbound/trunk@4787 be551aaa-1e26-0410-a405-d3ace91eadb9 --- diff --git a/doc/Changelog b/doc/Changelog index 3461722b4..4b3b61c39 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -4,6 +4,7 @@ in the ssl library. - Fix that ratelimit and ip-ratelimit are applied after reload of changed config file. + - Resize ratelimit and ip-ratelimit caches if changed on reload. 16 July 2018: Wouter - Fix qname minimisation NXDOMAIN validation lookup failures causing diff --git a/services/cache/infra.c b/services/cache/infra.c index 59f2eba89..a755e32de 100644 --- a/services/cache/infra.c +++ b/services/cache/infra.c @@ -299,8 +299,15 @@ infra_adjust(struct infra_cache* infra, struct config_file* cfg) infra_ip_ratelimit = cfg->ip_ratelimit; maxmem = cfg->infra_cache_numhosts * (sizeof(struct infra_key)+ sizeof(struct infra_data)+INFRA_BYTES_NAME); + /* divide cachesize by slabs and multiply by slabs, because if the + * cachesize is not an even multiple of slabs, that is the resulting + * size of the slabhash */ if(maxmem != slabhash_get_size(infra->hosts) || - cfg->infra_cache_slabs != infra->hosts->size) { + cfg->infra_cache_slabs != infra->hosts->size || + cfg->ratelimit_slabs != infra->domain_rates->size || + cfg->ratelimit_size/cfg->ratelimit_slabs*cfg->ratelimit_slabs != slabhash_get_size(infra->domain_rates) || + cfg->ip_ratelimit_slabs != infra->client_ip_rates->size || + cfg->ip_ratelimit_size/cfg->ip_ratelimit_slabs*cfg->ip_ratelimit_slabs != slabhash_get_size(infra->client_ip_rates)) { infra_delete(infra); infra = infra_create(cfg); } else {