From: Vladimír Čunát Date: Thu, 8 Apr 2021 13:30:34 +0000 (+0200) Subject: dnstap: fix repeated configuration X-Git-Tag: v5.3.2~13^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e7a29fd3e99d8491450bec4f69b71271ee4f3285;p=thirdparty%2Fknot-resolver.git dnstap: fix repeated configuration 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. --- diff --git a/NEWS b/NEWS index a9e431ff1..cf8c8f4e3 100644 --- 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) ================================ diff --git a/modules/dnstap/dnstap.c b/modules/dnstap/dnstap.c index 6dd6f9512..5ddc960bc 100644 --- a/modules/dnstap/dnstap.c +++ b/modules/dnstap/dnstap.c @@ -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;