void daemon_apply_cfg(struct daemon* daemon, struct config_file* cfg) { daemon->cfg = cfg; config_apply(cfg); if(!slabhash_is_size(daemon->env->msg_cache, cfg->msg_cache_size, cfg->msg_cache_slabs)) { slabhash_delete(daemon->env->msg_cache); daemon->env->msg_cache = slabhash_create(cfg->msg_cache_slabs, HASH_DEFAULT_STARTARRAY, cfg->msg_cache_size, msgreply_sizefunc, query_info_compare, query_entry_delete, reply_info_delete, NULL); if(!daemon->env->msg_cache) { fatal_exit("malloc failure updating config settings"); } } if((daemon->env->rrset_cache = rrset_cache_adjust( daemon->env->rrset_cache, cfg, &daemon->superalloc)) == 0) fatal_exit("malloc failure updating config settings"); if((daemon->env->infra_cache = infra_adjust(daemon->env->infra_cache, cfg))==0) fatal_exit("malloc failure updating config settings"); }
int context_finalize(struct ub_ctx* ctx) { struct config_file* cfg = ctx->env->cfg; verbosity = cfg->verbosity; if(ctx->logfile_override) log_file(ctx->log_out); else log_init(cfg->logfile, cfg->use_syslog, NULL); config_apply(cfg); if(!modstack_setup(&ctx->mods, cfg->module_conf, ctx->env)) return UB_INITFAIL; ctx->local_zones = local_zones_create(); if(!ctx->local_zones) return UB_NOMEM; if(!local_zones_apply_cfg(ctx->local_zones, cfg)) 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) { slabhash_delete(ctx->env->msg_cache); ctx->env->msg_cache = slabhash_create(cfg->msg_cache_slabs, HASH_DEFAULT_STARTARRAY, cfg->msg_cache_size, msgreply_sizefunc, query_info_compare, query_entry_delete, reply_info_delete, NULL); if(!ctx->env->msg_cache) return UB_NOMEM; } ctx->env->rrset_cache = rrset_cache_adjust(ctx->env->rrset_cache, ctx->env->cfg, ctx->env->alloc); if(!ctx->env->rrset_cache) return UB_NOMEM; ctx->env->infra_cache = infra_adjust(ctx->env->infra_cache, cfg); if(!ctx->env->infra_cache) return UB_NOMEM; ctx->finalized = 1; return UB_NOERROR; }