]> git.ipfire.org Git - thirdparty/knot-dns.git/commitdiff
conf: remove useless mm_ctx
authorDaniel Salzman <daniel.salzman@nic.cz>
Tue, 5 Jun 2018 14:12:25 +0000 (16:12 +0200)
committerDaniel Salzman <daniel.salzman@nic.cz>
Tue, 5 Jun 2018 14:23:24 +0000 (16:23 +0200)
src/knot/conf/base.c
src/knot/conf/base.h
src/knot/conf/confio.c
src/knot/conf/module.c
src/knot/nameserver/query_module.c
src/knot/nameserver/query_module.h
tests/knot/test_query_module.c

index 1f1928c4da6b92659592337ee5292a33c255033a..c6d87ab284d992abfbe30820ce95bedbf0e11e1f 100644 (file)
@@ -27,7 +27,6 @@
 #include "libknot/yparser/ypformat.h"
 #include "libknot/yparser/yptrafo.h"
 #include "contrib/files.h"
-#include "contrib/mempattern.h"
 #include "contrib/sockaddr.h"
 #include "contrib/string.h"
 
@@ -166,16 +165,8 @@ int conf_new(
                goto new_error;
        }
 
-       // Initialize a config mempool.
-       out->mm = malloc(sizeof(knot_mm_t));
-       if (out->mm == NULL) {
-               ret = KNOT_ENOMEM;
-               goto new_error;
-       }
-       mm_ctx_init(out->mm);
-
        // Initialize query modules list.
-       out->query_modules = mm_alloc(out->mm, sizeof(list_t));
+       out->query_modules = malloc(sizeof(list_t));
        if (out->query_modules == NULL) {
                ret = KNOT_ENOMEM;
                goto new_error;
@@ -201,7 +192,7 @@ int conf_new(
                        goto new_error;
                }
 
-               ret = out->api->init(&out->db, out->mm, &lmdb_opts);
+               ret = out->api->init(&out->db, NULL, &lmdb_opts);
 
                // Remove the database to ensure it is temporary.
                if (!remove_path(lmdb_opts.path)) {
@@ -217,7 +208,7 @@ int conf_new(
                        lmdb_opts.flags.env |= KNOT_DB_LMDB_RDONLY;
                }
 
-               ret = out->api->init(&out->db, out->mm, &lmdb_opts);
+               ret = out->api->init(&out->db, NULL, &lmdb_opts);
        }
        if (ret != KNOT_EOK) {
                goto new_error;
@@ -295,11 +286,10 @@ int conf_clone(
 
        // Set shared items.
        out->api = s_conf->api;
-       out->mm = s_conf->mm;
        out->db = s_conf->db;
 
        // Initialize query modules list.
-       out->query_modules = mm_alloc(out->mm, sizeof(list_t));
+       out->query_modules = malloc(sizeof(list_t));
        if (out->query_modules == NULL) {
                yp_schema_free(out->schema);
                free(out);
@@ -310,7 +300,7 @@ int conf_clone(
        // Open common read-only transaction.
        ret = conf_refresh_txn(out);
        if (ret != KNOT_EOK) {
-               mm_free(out->mm, out->query_modules);
+               free(out->query_modules);
                yp_schema_free(out->schema);
                free(out);
                return ret;
@@ -349,7 +339,7 @@ conf_t *conf_update(
                        conf->io.zones = s_conf->io.zones;
                }
                if ((flags & CONF_UPD_FMODULES) && s_conf != NULL) {
-                       mm_free(conf->mm, conf->query_modules);
+                       free(conf->query_modules);
                        conf->query_modules = s_conf->query_modules;
                        conf->query_plan = s_conf->query_plan;
                }
@@ -403,16 +393,13 @@ void conf_free(
 
        conf_mod_load_purge(conf, false);
        conf_deactivate_modules(conf->query_modules, &conf->query_plan);
-       mm_free(conf->mm, conf->query_modules);
+       free(conf->query_modules);
        conf_mod_unload_shared(conf);
 
        if (!conf->is_clone) {
                if (conf->api != NULL) {
                        conf->api->deinit(conf->db);
                }
-               if (conf->mm != NULL) {
-                       free(conf->mm);
-               }
        }
 
        free(conf);
index b47f510e4cb293a2c80d6402a53d24cfe6f1b640..31f307994dfcf5e8e722bf7c4bb89866df0c9ef3 100644 (file)
@@ -81,8 +81,6 @@ typedef struct {
        const struct knot_db_api *api;
        /*! Configuration schema. */
        yp_item_t *schema;
-       /*! Memory context. */
-       knot_mm_t *mm;
        /*! Configuration database. */
        knot_db_t *db;
 
index 56fe993ce03c8996b5111bdcc737fdc2994ff75f..b64b279241264b655928d4b39380b40b27f50f33 100644 (file)
@@ -1,4 +1,4 @@
-/*  Copyright (C) 2017 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
+/*  Copyright (C) 2018 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
 
     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
@@ -824,7 +824,7 @@ static void upd_changes(
        // Prepare zone changes storage if it doesn't exist.
        trie_t *zones = conf()->io.zones;
        if (zones == NULL) {
-               zones = trie_create(conf()->mm);
+               zones = trie_create(NULL);
                if (zones == NULL) {
                        return;
                }
index 73c31fc0a584bc112f088c1125a472d272e5841f..073bc067b99b1e18d2d694d97783680e9b353652 100644 (file)
@@ -378,7 +378,7 @@ void conf_activate_modules(
        }
 
        // Create query plan.
-       *query_plan = query_plan_create(conf->mm);
+       *query_plan = query_plan_create();
        if (*query_plan == NULL) {
                ret = KNOT_ENOMEM;
                goto activate_error;
index 73aa384ebc1ba6d8341213089b6d884e32038213..26b32cea307926d845f3dc07de2e2bcd435ac556 100644 (file)
@@ -26,7 +26,6 @@
 #include "knot/conf/tools.h"
 #include "knot/nameserver/query_module.h"
 #include "knot/nameserver/process_query.h"
-#include "contrib/mempattern.h"
 
 #ifdef HAVE_ATOMIC
  #define ATOMIC_ADD(dst, val) __atomic_add_fetch(&(dst), (val), __ATOMIC_RELAXED)
@@ -45,14 +44,13 @@ int knotd_conf_check_ref(knotd_conf_check_args_t *args)
        return check_ref(args);
 }
 
-struct query_plan *query_plan_create(knot_mm_t *mm)
+struct query_plan *query_plan_create(void)
 {
-       struct query_plan *plan = mm_alloc(mm, sizeof(struct query_plan));
+       struct query_plan *plan = malloc(sizeof(struct query_plan));
        if (plan == NULL) {
                return NULL;
        }
 
-       plan->mm = mm;
        for (unsigned i = 0; i < KNOTD_STAGES; ++i) {
                init_list(&plan->stage[i]);
        }
@@ -69,17 +67,16 @@ void query_plan_free(struct query_plan *plan)
        for (unsigned i = 0; i < KNOTD_STAGES; ++i) {
                struct query_step *step = NULL, *next = NULL;
                WALK_LIST_DELSAFE(step, next, plan->stage[i]) {
-                       mm_free(plan->mm, step);
+                       free(step);
                }
        }
 
-       mm_free(plan->mm, plan);
+       free(plan);
 }
 
-static struct query_step *make_step(knot_mm_t *mm, query_step_process_f process,
-                                    void *ctx)
+static struct query_step *make_step(query_step_process_f process, void *ctx)
 {
-       struct query_step *step = mm_calloc(mm, 1, sizeof(struct query_step));
+       struct query_step *step = calloc(1, sizeof(struct query_step));
        if (step == NULL) {
                return NULL;
        }
@@ -93,7 +90,7 @@ static struct query_step *make_step(knot_mm_t *mm, query_step_process_f process,
 int query_plan_step(struct query_plan *plan, knotd_stage_t stage,
                     query_step_process_f process, void *ctx)
 {
-       struct query_step *step = make_step(plan->mm, process, ctx);
+       struct query_step *step = make_step(process, ctx);
        if (step == NULL) {
                return KNOT_ENOMEM;
        }
index 0c4fdc19d307d245234d8b3f145f3deafb5c0c0e..a7a224f609b8966b798ab2d4368a41e4f81a4897 100644 (file)
@@ -44,12 +44,11 @@ struct query_step {
  *  assembly phase, for example 'before processing', 'answer section' and so on.
  */
 struct query_plan {
-       knot_mm_t *mm;
        list_t stage[KNOTD_STAGES];
 };
 
 /*! \brief Create an empty query plan. */
-struct query_plan *query_plan_create(knot_mm_t *mm);
+struct query_plan *query_plan_create(void);
 
 /*! \brief Free query plan and all planned steps. */
 void query_plan_free(struct query_plan *plan);
index e77f4b7653b901627e056d252a7b0a8a23b6a83c..cb4a606b3de5a6d3240a2f484b3d681d51efbde8 100644 (file)
@@ -1,4 +1,4 @@
-/*  Copyright (C) 2017 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
+/*  Copyright (C) 2018 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
 
     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
@@ -21,8 +21,6 @@
 #include "libknot/libknot.h"
 #include "knot/nameserver/query_module.h"
 #include "libknot/packet/pkt.h"
-#include "contrib/mempattern.h"
-#include "contrib/ucw/mempool.h"
 
 /* Universal processing stage. */
 unsigned state_visit(unsigned state, knot_pkt_t *pkt, knotd_qdata_t *qdata,
@@ -39,15 +37,11 @@ int main(int argc, char *argv[])
 {
        plan_lazy();
 
-       /* Create processing context. */
-       knot_mm_t mm;
-       mm_ctx_mempool(&mm, MM_DEFAULT_BLKSIZE);
-
        /* Create a map of expected steps. */
        bool state_map[KNOTD_STAGES] = { false };
 
        /* Prepare query plan. */
-       struct query_plan *plan = query_plan_create(&mm);
+       struct query_plan *plan = query_plan_create();
        ok(plan != NULL, "query_plan: create");
 
        /* Register all stage visits. */
@@ -85,8 +79,5 @@ int main(int argc, char *argv[])
        /* Free the query plan. */
        query_plan_free(plan);
 
-       /* Cleanup. */
-       mp_delete((struct mempool *)mm.ctx);
-
        return 0;
 }