]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
dnstap: fix repeated configuration
authorVladimír Čunát <vladimir.cunat@nic.cz>
Thu, 8 Apr 2021 13:30:34 +0000 (15:30 +0200)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Thu, 8 Apr 2021 13:49:49 +0000 (15:49 +0200)
In practice it can easily happen, as loading module and really
configuring it is often done separately.  Then we'd see two fstrm
threads, etc.

NEWS
modules/dnstap/dnstap.c

diff --git a/NEWS b/NEWS
index a9e431ff1ee8d39f780280657fe0a6618d978b8c..cf8c8f4e3af708b0b95f46a243a2f257d6d6b489 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,11 @@
+Knot Resolver 5.3.2 (2021-0m-dd)
+================================
+
+Bugfixes
+--------
+- dnstap module: fix repeated configuration (!1168)
+
+
 Knot Resolver 5.3.1 (2021-03-31)
 ================================
 
index 6dd6f951275329d48be776edf33c8da7cd12ef65..5ddc960bca799aceb5d1d6ace8e0d64b4f44d410 100644 (file)
@@ -271,18 +271,22 @@ int dnstap_init(struct kr_module *module) {
        return kr_ok();
 }
 
-KR_EXPORT
-int dnstap_deinit(struct kr_module *module) {
+/** Clear, i.e. get to state as after the first dnstap_init(). */
+static void dnstap_clear(struct kr_module *module) {
        struct dnstap_data *data = module->data;
-       /* Free allocated memory */
        if (data) {
                free(data->identity);
                free(data->version);
 
                fstrm_iothr_destroy(&data->iothread);
                DEBUG_MSG("fstrm iothread destroyed\n");
-               free(data);
        }
+}
+
+KR_EXPORT
+int dnstap_deinit(struct kr_module *module) {
+       dnstap_clear(module);
+       free(module->data);
        return kr_ok();
 }
 
@@ -350,6 +354,7 @@ static bool find_bool(const JsonNode *node) {
 /* parse config */
 KR_EXPORT
 int dnstap_config(struct kr_module *module, const char *conf) {
+       dnstap_clear(module);
        struct dnstap_data *data = module->data;
        auto_free char *sock_path = NULL;