From: Daniel Salzman Date: Fri, 18 May 2018 14:34:44 +0000 (+0200) Subject: conf: fix creeping memory consumption upon reload X-Git-Tag: v2.7.0~80 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=32f84cf89971ccfaa9e22e052c5062a32ea774ff;p=thirdparty%2Fknot-dns.git conf: fix creeping memory consumption upon reload --- diff --git a/src/knot/conf/base.c b/src/knot/conf/base.c index e929b3490e..c12fbc52b3 100644 --- a/src/knot/conf/base.c +++ b/src/knot/conf/base.c @@ -30,7 +30,6 @@ #include "contrib/mempattern.h" #include "contrib/sockaddr.h" #include "contrib/string.h" -#include "contrib/ucw/mempool.h" // The active configuration. conf_t *s_conf; @@ -170,7 +169,7 @@ int conf_new( ret = KNOT_ENOMEM; goto new_error; } - mm_ctx_mempool(out->mm, MM_DEFAULT_BLKSIZE); + mm_ctx_init(out->mm); // Initialize query modules list. out->query_modules = mm_alloc(out->mm, sizeof(list_t)); @@ -396,7 +395,6 @@ void conf_free( } if (conf->io.zones != NULL) { trie_free(conf->io.zones); - mm_free(conf->mm, conf->io.zones); } conf_mod_load_purge(conf, false); @@ -409,7 +407,6 @@ void conf_free( conf->api->deinit(conf->db); } if (conf->mm != NULL) { - mp_delete(conf->mm->ctx); free(conf->mm); } } diff --git a/src/libknot/control/control.c b/src/libknot/control/control.c index 8591519f50..af68cfe9a2 100644 --- a/src/libknot/control/control.c +++ b/src/libknot/control/control.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2016 CZ.NIC, z.s.p.o. +/* Copyright (C) 2018 CZ.NIC, z.s.p.o. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -126,12 +126,8 @@ static void reset_buffers(knot_ctl_t *ctx) static void clean_data(knot_ctl_t *ctx) { - for (knot_ctl_idx_t i = 0; i < KNOT_CTL_IDX__COUNT; i++) { - if (ctx->data[i] != NULL) { - mm_free(&ctx->mm, (void *)ctx->data[i]); - ctx->data[i] = NULL; - } - } + mp_flush(ctx->mm.ctx); + memset(ctx->data, 0, sizeof(ctx->data)); } static void close_sock(int *sock)