]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
Fixup cache size test for msg cache.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Tue, 17 Jul 2018 14:56:02 +0000 (14:56 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Tue, 17 Jul 2018 14:56:02 +0000 (14:56 +0000)
git-svn-id: file:///svn/unbound/trunk@4789 be551aaa-1e26-0410-a405-d3ace91eadb9

daemon/daemon.c
libunbound/context.c
services/cache/infra.c

index 994489e2102277146ca9c64a220560bd6ef353a5..b98f18c0cd8367c3b7c0d8446382dd22ba394b87 100644 (file)
@@ -804,8 +804,8 @@ void daemon_apply_cfg(struct daemon* daemon, struct config_file* cfg)
         daemon->cfg = cfg;
        config_apply(cfg);
        if(!daemon->env->msg_cache ||
-          cfg->msg_cache_size != slabhash_get_size(daemon->env->msg_cache) ||
-          cfg->msg_cache_slabs != daemon->env->msg_cache->size) {
+          cfg->msg_cache_slabs != daemon->env->msg_cache->size ||
+          (cfg->msg_cache_size/cfg->msg_cache_slabs)*cfg->msg_cache_slabs != slabhash_get_size(daemon->env->msg_cache)) {
                slabhash_delete(daemon->env->msg_cache);
                daemon->env->msg_cache = slabhash_create(cfg->msg_cache_slabs,
                        HASH_DEFAULT_STARTARRAY, cfg->msg_cache_size,
index 6ac8086bf6727232156c77705a5aa27421e110f5..dbe1cfcb097126a7069a4dbc126f0840fa60935d 100644 (file)
@@ -72,8 +72,8 @@ context_finalize(struct ub_ctx* ctx)
        if(!auth_zones_apply_cfg(ctx->env->auth_zones, cfg, 1))
                return UB_INITFAIL;
        if(!ctx->env->msg_cache ||
-          cfg->msg_cache_size != slabhash_get_size(ctx->env->msg_cache) || 
-          cfg->msg_cache_slabs != ctx->env->msg_cache->size) {
+          cfg->msg_cache_slabs != ctx->env->msg_cache->size ||
+          (cfg->msg_cache_size/cfg->msg_cache_slabs)*cfg->msg_cache_slabs != slabhash_get_size(ctx->env->msg_cache)) {
                slabhash_delete(ctx->env->msg_cache);
                ctx->env->msg_cache = slabhash_create(cfg->msg_cache_slabs,
                        HASH_DEFAULT_STARTARRAY, cfg->msg_cache_size,
index 6a427d19790f6ee51b920e6b255b9d5b21062c9d..2b9b96e873eab0e4ee27278a455e75cfce432bc2 100644 (file)
@@ -302,7 +302,7 @@ infra_adjust(struct infra_cache* infra, struct config_file* cfg)
        /* 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) ||
+       if((maxmem/cfg->infra_cache_slabs)*cfg->infra_cache_slabs != slabhash_get_size(infra->hosts) ||
                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) ||