From: Ondřej Surý Date: Tue, 4 Feb 2025 12:17:31 +0000 (+0100) Subject: Move the library init and shutdown to executables X-Git-Tag: ondrej/lock-free-qpzone-reads-v1~36^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f5c204ac3efd3c94603a319347b03aca3dc914af;p=thirdparty%2Fbind9.git Move the library init and shutdown to executables Instead of relying on unreliable order of execution of the library constructors and destructors, move them to individual binaries. The advantage is that the execution time and order will remain constant and will not depend on the dynamic load dependency solver. This requires more work, but that was mitigated by a simple requirement, any executable using libisc and libdns, must include and respectively (in this particular order). In turn, these two headers must not be included from within any library as they contain inlined functions marked with constructor/destructor attributes. --- diff --git a/bin/check/named-checkconf.c b/bin/check/named-checkconf.c index 26c3106547f..e0210cfbd38 100644 --- a/bin/check/named-checkconf.c +++ b/bin/check/named-checkconf.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -30,6 +31,7 @@ #include #include +#include #include #include #include diff --git a/bin/check/named-checkzone.c b/bin/check/named-checkzone.c index db5289d1e31..998171662cc 100644 --- a/bin/check/named-checkzone.c +++ b/bin/check/named-checkzone.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -31,6 +32,7 @@ #include #include +#include #include #include #include diff --git a/bin/confgen/rndc-confgen.c b/bin/confgen/rndc-confgen.c index 31cfe21aa54..a6526268b4d 100644 --- a/bin/confgen/rndc-confgen.c +++ b/bin/confgen/rndc-confgen.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -40,6 +41,7 @@ #include #include +#include #include #include diff --git a/bin/confgen/tsig-keygen.c b/bin/confgen/tsig-keygen.c index 9dede3e3cf7..ee6470d9e9b 100644 --- a/bin/confgen/tsig-keygen.c +++ b/bin/confgen/tsig-keygen.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -36,6 +37,7 @@ #include #include +#include #include #include diff --git a/bin/delv/delv.c b/bin/delv/delv.c index 64bbfa7d423..2088088d464 100644 --- a/bin/delv/delv.c +++ b/bin/delv/delv.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -59,6 +60,7 @@ #include #include #include +#include #include #include #include diff --git a/bin/dig/dig.c b/bin/dig/dig.c index 67056ec490b..eb4290a0dd5 100644 --- a/bin/dig/dig.c +++ b/bin/dig/dig.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -33,6 +34,7 @@ #include #include #include +#include #include #include #include diff --git a/bin/dig/host.c b/bin/dig/host.c index 6ecf441e8db..1f93d8eb720 100644 --- a/bin/dig/host.c +++ b/bin/dig/host.c @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -28,6 +29,7 @@ #include #include +#include #include #include #include diff --git a/bin/dig/nslookup.c b/bin/dig/nslookup.c index bef5822b375..ca362918814 100644 --- a/bin/dig/nslookup.c +++ b/bin/dig/nslookup.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -30,6 +31,7 @@ #include #include +#include #include #include #include diff --git a/bin/dnssec/dnssec-cds.c b/bin/dnssec/dnssec-cds.c index 70f8f477c7f..fbf319c356b 100644 --- a/bin/dnssec/dnssec-cds.c +++ b/bin/dnssec/dnssec-cds.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -44,6 +45,7 @@ #include #include #include +#include #include #include #include diff --git a/bin/dnssec/dnssec-dsfromkey.c b/bin/dnssec/dnssec-dsfromkey.c index 8a8b03c2d9a..00c1bab86e4 100644 --- a/bin/dnssec/dnssec-dsfromkey.c +++ b/bin/dnssec/dnssec-dsfromkey.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -34,6 +35,7 @@ #include #include #include +#include #include #include #include diff --git a/bin/dnssec/dnssec-importkey.c b/bin/dnssec/dnssec-importkey.c index 6e9f3e3af13..95ac0256bae 100644 --- a/bin/dnssec/dnssec-importkey.c +++ b/bin/dnssec/dnssec-importkey.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -32,6 +33,7 @@ #include #include #include +#include #include #include #include diff --git a/bin/dnssec/dnssec-keyfromlabel.c b/bin/dnssec/dnssec-keyfromlabel.c index c302528c77f..3b8899960ba 100644 --- a/bin/dnssec/dnssec-keyfromlabel.c +++ b/bin/dnssec/dnssec-keyfromlabel.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -31,6 +32,7 @@ #include #include #include +#include #include #include #include diff --git a/bin/dnssec/dnssec-keygen.c b/bin/dnssec/dnssec-keygen.c index 849327e61db..36ed720ec8f 100644 --- a/bin/dnssec/dnssec-keygen.c +++ b/bin/dnssec/dnssec-keygen.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -50,6 +51,7 @@ #include #include #include +#include #include #include #include diff --git a/bin/dnssec/dnssec-ksr.c b/bin/dnssec/dnssec-ksr.c index 0a929ee3b26..95b1e4b7e54 100644 --- a/bin/dnssec/dnssec-ksr.c +++ b/bin/dnssec/dnssec-ksr.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -27,6 +28,7 @@ #include #include #include +#include #include #include #include diff --git a/bin/dnssec/dnssec-revoke.c b/bin/dnssec/dnssec-revoke.c index 603ec000e42..5f54ad297cf 100644 --- a/bin/dnssec/dnssec-revoke.c +++ b/bin/dnssec/dnssec-revoke.c @@ -23,12 +23,14 @@ #include #include #include +#include #include #include #include #include #include +#include #include diff --git a/bin/dnssec/dnssec-settime.c b/bin/dnssec/dnssec-settime.c index e70e95cbda1..7f14e0fc38b 100644 --- a/bin/dnssec/dnssec-settime.c +++ b/bin/dnssec/dnssec-settime.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -33,6 +34,7 @@ #include #include +#include #include diff --git a/bin/dnssec/dnssec-signzone.c b/bin/dnssec/dnssec-signzone.c index 748f28f3bcd..8461134e674 100644 --- a/bin/dnssec/dnssec-signzone.c +++ b/bin/dnssec/dnssec-signzone.c @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -71,6 +72,7 @@ #include #include #include +#include #include #include #include diff --git a/bin/dnssec/dnssec-verify.c b/bin/dnssec/dnssec-verify.c index 2c22e3f8cf8..14a19277b0e 100644 --- a/bin/dnssec/dnssec-verify.c +++ b/bin/dnssec/dnssec-verify.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -43,6 +44,7 @@ #include #include #include +#include #include #include #include diff --git a/bin/named/main.c b/bin/named/main.c index c7547da9c96..81af56c1538 100644 --- a/bin/named/main.c +++ b/bin/named/main.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -47,6 +48,7 @@ #include #include +#include #include #include #include diff --git a/bin/named/server.c b/bin/named/server.c index 14bf29d8267..2310b167ec2 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -7912,7 +7912,7 @@ load_configuration(const char *filename, named_server_t *server, /* * Shut down all dyndb instances. */ - dns_dyndb_cleanup(false); + dns_dyndb_cleanup(); /* * Parse the global default pseudo-config file. @@ -9591,7 +9591,7 @@ shutdown_server(void *arg) { /* * Shut down all dyndb instances. */ - dns_dyndb_cleanup(true); + dns_dyndb_cleanup(); while ((nsc = ISC_LIST_HEAD(server->cachelist)) != NULL) { ISC_LIST_UNLINK(server->cachelist, nsc, link); diff --git a/bin/named/statschannel.c b/bin/named/statschannel.c index 8b1a1cd91ca..4df131de2f9 100644 --- a/bin/named/statschannel.c +++ b/bin/named/statschannel.c @@ -97,7 +97,7 @@ typedef struct stats_dumparg { isc_result_t result; } stats_dumparg_t; -static isc_once_t once = ISC_ONCE_INIT; +static isc_once_t once = ISC_ONCE_INITIALIZER; #if defined(HAVE_LIBXML2) || defined(HAVE_JSON_C) #define EXTENDED_STATS diff --git a/bin/nsupdate/nsupdate.c b/bin/nsupdate/nsupdate.c index 524c9ac3f3e..93e05a30fa0 100644 --- a/bin/nsupdate/nsupdate.c +++ b/bin/nsupdate/nsupdate.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -52,6 +53,7 @@ #include #include #include +#include #include #include #include diff --git a/bin/rndc/rndc.c b/bin/rndc/rndc.c index 38b1caf7755..1e9e1f0d1a0 100644 --- a/bin/rndc/rndc.c +++ b/bin/rndc/rndc.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -36,6 +37,7 @@ #include #include +#include #include #include diff --git a/bin/tests/system/feature-test.c b/bin/tests/system/feature-test.c index 11481f3bbb6..f39922dcbc1 100644 --- a/bin/tests/system/feature-test.c +++ b/bin/tests/system/feature-test.c @@ -24,12 +24,14 @@ #endif #include +#include #include #include #include #include #include +#include #include diff --git a/bin/tests/system/makejournal.c b/bin/tests/system/makejournal.c index 1cbe75b699d..94a92b9a737 100644 --- a/bin/tests/system/makejournal.c +++ b/bin/tests/system/makejournal.c @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -25,6 +26,7 @@ #include #include #include +#include #include #include diff --git a/bin/tests/system/pipelined/pipequeries.c b/bin/tests/system/pipelined/pipequeries.c index c9b7f6a1198..fcfb50ccd02 100644 --- a/bin/tests/system/pipelined/pipequeries.c +++ b/bin/tests/system/pipelined/pipequeries.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -33,6 +34,7 @@ #include #include +#include #include #include #include diff --git a/bin/tests/system/rsabigexponent/bigkey.c b/bin/tests/system/rsabigexponent/bigkey.c index a8d4241c2a0..2ae0f3dec09 100644 --- a/bin/tests/system/rsabigexponent/bigkey.c +++ b/bin/tests/system/rsabigexponent/bigkey.c @@ -15,12 +15,15 @@ #include #include +#include #include #include #include #include #include +#include + #define DST_KEY_INTERNAL #include diff --git a/bin/tests/test_client.c b/bin/tests/test_client.c index 25a341d177c..4d737bc0549 100644 --- a/bin/tests/test_client.c +++ b/bin/tests/test_client.c @@ -25,6 +25,7 @@ #include #include +#include #include #include #include diff --git a/bin/tests/test_server.c b/bin/tests/test_server.c index beb723a65c2..b26ea20dab8 100644 --- a/bin/tests/test_server.c +++ b/bin/tests/test_server.c @@ -19,6 +19,7 @@ #include #include +#include #include #include #include diff --git a/bin/tests/wire_test.c b/bin/tests/wire_test.c index 26a84c4bace..bf130c7fc3c 100644 --- a/bin/tests/wire_test.c +++ b/bin/tests/wire_test.c @@ -18,11 +18,13 @@ #include #include #include +#include #include #include #include #include +#include #include int parseflags = 0; diff --git a/bin/tools/arpaname.c b/bin/tools/arpaname.c index 5428c97672a..bf47f601b64 100644 --- a/bin/tools/arpaname.c +++ b/bin/tools/arpaname.c @@ -13,6 +13,7 @@ #include +#include #include #define UNUSED(x) (void)(x) diff --git a/bin/tools/dnstap-read.c b/bin/tools/dnstap-read.c index 9127fba967e..501d70ad96d 100644 --- a/bin/tools/dnstap-read.c +++ b/bin/tools/dnstap-read.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -47,6 +48,7 @@ #include #include +#include #include #include #include diff --git a/bin/tools/mdig.c b/bin/tools/mdig.c index c4880041a90..58d60b42b55 100644 --- a/bin/tools/mdig.c +++ b/bin/tools/mdig.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -41,6 +42,7 @@ #include #include #include +#include #include #include #include diff --git a/bin/tools/named-journalprint.c b/bin/tools/named-journalprint.c index f5eb1e23689..c8fcc2b75e6 100644 --- a/bin/tools/named-journalprint.c +++ b/bin/tools/named-journalprint.c @@ -16,12 +16,14 @@ #include #include +#include #include #include #include #include #include +#include #include const char *progname = NULL; diff --git a/bin/tools/named-nzd2nzf.c b/bin/tools/named-nzd2nzf.c index 42be33f7fcd..18a5791ea88 100644 --- a/bin/tools/named-nzd2nzf.c +++ b/bin/tools/named-nzd2nzf.c @@ -19,6 +19,9 @@ #include #include +#include + +/* Included just to get DNS_LMDB_FLAGS definition */ #include int diff --git a/bin/tools/named-rrchecker.c b/bin/tools/named-rrchecker.c index d856756a5c1..2de1d31bf86 100644 --- a/bin/tools/named-rrchecker.c +++ b/bin/tools/named-rrchecker.c @@ -19,12 +19,14 @@ #include #include #include +#include #include #include #include #include #include +#include #include #include #include diff --git a/bin/tools/nsec3hash.c b/bin/tools/nsec3hash.c index dbba2d91b46..0ddc6fa067f 100644 --- a/bin/tools/nsec3hash.c +++ b/bin/tools/nsec3hash.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -30,6 +31,7 @@ #include #include +#include #include #include #include diff --git a/doc/misc/cfg_test.c b/doc/misc/cfg_test.c index e0df72edb40..64c64d27000 100644 --- a/doc/misc/cfg_test.c +++ b/doc/misc/cfg_test.c @@ -17,6 +17,7 @@ #include #include +#include #include #include #include diff --git a/fuzz/main.c b/fuzz/main.c index 9863df52f2a..86fa159e33b 100644 --- a/fuzz/main.c +++ b/fuzz/main.c @@ -20,6 +20,10 @@ #include #include +#include + +#include + #include "fuzz.h" #ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION diff --git a/lib/dns/Makefile.am b/lib/dns/Makefile.am index 1733fdccf41..a93feaebfb0 100644 --- a/lib/dns/Makefile.am +++ b/lib/dns/Makefile.am @@ -86,6 +86,7 @@ libdns_la_HEADERS = \ include/dns/keystore.h \ include/dns/keytable.h \ include/dns/keyvalues.h \ + include/dns/lib.h \ include/dns/master.h \ include/dns/masterdump.h \ include/dns/message.h \ @@ -153,6 +154,7 @@ libdns_la_SOURCES = \ $(dst_HEADERS) \ $(irs_HEADERS) \ acl.c \ + acl_p.h \ adb.c \ badcache.c \ byaddr.c \ @@ -168,6 +170,7 @@ libdns_la_SOURCES = \ diff.c \ dispatch.c \ dlz.c \ + dlz_p.h \ dns64.c \ dnssec.c \ ds.c \ @@ -177,6 +180,7 @@ libdns_la_SOURCES = \ dst_parse.c \ dst_parse.h \ dyndb.c \ + dyndb_p.h \ ecs.c \ ede.c \ fixedname.c \ @@ -192,6 +196,7 @@ libdns_la_SOURCES = \ keymgr.c \ keystore.c \ keytable.c \ + lib.c \ master.c \ masterdump.c \ message.c \ diff --git a/lib/dns/acl.c b/lib/dns/acl.c index 244995c9957..c0e51f55a71 100644 --- a/lib/dns/acl.c +++ b/lib/dns/acl.c @@ -25,6 +25,8 @@ #include #include +#include "acl_p.h" + #define DNS_ACLENV_MAGIC ISC_MAGIC('a', 'c', 'n', 'v') #define VALID_ACLENV(a) ISC_MAGIC_VALID(a, DNS_ACLENV_MAGIC) @@ -507,15 +509,19 @@ ISC_REFCOUNT_TRACE_IMPL(dns_acl, dns__acl_destroy); ISC_REFCOUNT_IMPL(dns_acl, dns__acl_destroy); #endif -static isc_once_t insecure_prefix_once = ISC_ONCE_INIT; static isc_mutex_t insecure_prefix_lock; static bool insecure_prefix_found; -static void -initialize_action(void) { +void +dns__acl_initialize(void) { isc_mutex_init(&insecure_prefix_lock); } +void +dns__acl_shutdown(void) { + isc_mutex_destroy(&insecure_prefix_lock); +} + /* * Called via isc_radix_process() to find IP table nodes that are * insecure. @@ -566,8 +572,6 @@ dns_acl_isinsecure(const dns_acl_t *a) { unsigned int i; bool insecure; - isc_once_do(&insecure_prefix_once, initialize_action); - /* * Walk radix tree to find out if there are any non-negated, * non-loopback prefixes. diff --git a/lib/dns/acl_p.h b/lib/dns/acl_p.h new file mode 100644 index 00000000000..8ab305ff3bc --- /dev/null +++ b/lib/dns/acl_p.h @@ -0,0 +1,21 @@ +/* + * Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * SPDX-License-Identifier: MPL-2.0 + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, you can obtain one at https://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + +#pragma once + +/*! \file */ + +void +dns__acl_initialize(void); +void +dns__acl_shutdown(void); diff --git a/lib/dns/db.c b/lib/dns/db.c index 8add76f6441..90ac276bc53 100644 --- a/lib/dns/db.c +++ b/lib/dns/db.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -69,13 +68,12 @@ unsigned int dns_pps = 0U; static ISC_LIST(dns_dbimplementation_t) implementations; static isc_rwlock_t implock; -static isc_once_t once = ISC_ONCE_INIT; static dns_dbimplementation_t qpimp; static dns_dbimplementation_t qpzoneimp; -static void -initialize(void) { +void +dns__db_initialize(void) { isc_rwlock_init(&implock); ISC_LIST_INIT(implementations); @@ -96,6 +94,11 @@ initialize(void) { ISC_LIST_APPEND(implementations, &qpzoneimp, link); } +void +dns__db_shutdown(void) { + isc_rwlock_destroy(&implock); +} + static dns_dbimplementation_t * impfind(const char *name) { dns_dbimplementation_t *imp; @@ -123,8 +126,6 @@ dns_db_create(isc_mem_t *mctx, const char *db_type, const dns_name_t *origin, char *argv[], dns_db_t **dbp) { dns_dbimplementation_t *impinfo = NULL; - isc_once_do(&once, initialize); - /* * Create a new database using implementation 'db_type'. */ @@ -831,8 +832,6 @@ dns_db_register(const char *name, dns_dbcreatefunc_t create, void *driverarg, REQUIRE(name != NULL); REQUIRE(dbimp != NULL && *dbimp == NULL); - isc_once_do(&once, initialize); - RWLOCK(&implock, isc_rwlocktype_write); imp = impfind(name); if (imp != NULL) { @@ -861,8 +860,6 @@ dns_db_unregister(dns_dbimplementation_t **dbimp) { REQUIRE(dbimp != NULL && *dbimp != NULL); - isc_once_do(&once, initialize); - imp = *dbimp; *dbimp = NULL; RWLOCK(&implock, isc_rwlocktype_write); diff --git a/lib/dns/db_p.h b/lib/dns/db_p.h index 132f8e04640..2db152ec1f9 100644 --- a/lib/dns/db_p.h +++ b/lib/dns/db_p.h @@ -193,3 +193,11 @@ dns__db_logtoomanyrecords(dns_db_t *db, const dns_name_t *name, * 'maxrrperset' limit. 'op' is 'adding' or 'updating' depending on whether * the addition is to create a new rdataset or to merge to an existing one. */ + +/*% + * Internal dns_db constructor and destructor. + */ +void +dns__db_initialize(void); +void +dns__db_shutdown(void); diff --git a/lib/dns/dlz.c b/lib/dns/dlz.c index 1525db56b64..b6d41678edd 100644 --- a/lib/dns/dlz.c +++ b/lib/dns/dlz.c @@ -60,7 +60,6 @@ #include #include #include -#include #include #include #include @@ -73,20 +72,26 @@ #include #include +#include "dlz_p.h" + /*** *** Supported DLZ DB Implementations Registry ***/ static ISC_LIST(dns_dlzimplementation_t) dlz_implementations; static isc_rwlock_t dlz_implock; -static isc_once_t once = ISC_ONCE_INIT; -static void -dlz_initialize(void) { +void +dns__dlz_initialize(void) { isc_rwlock_init(&dlz_implock); ISC_LIST_INIT(dlz_implementations); } +void +dns__dlz_shutdown(void) { + isc_rwlock_destroy(&dlz_implock); +} + /*% * Searches the dlz_implementations list for a driver matching name. */ @@ -162,12 +167,6 @@ dns_dlzcreate(isc_mem_t *mctx, const char *dlzname, const char *drivername, isc_result_t result; dns_dlzdb_t *db = NULL; - /* - * initialize the dlz_implementations list, this is guaranteed - * to only really happen once. - */ - isc_once_do(&once, dlz_initialize); - /* * Performs checks to make sure data is as we expect it to be. */ @@ -291,12 +290,6 @@ dns_dlzregister(const char *drivername, const dns_dlzmethods_t *methods, REQUIRE(mctx != NULL); REQUIRE(dlzimp != NULL && *dlzimp == NULL); - /* - * initialize the dlz_implementations list, this is guaranteed - * to only really happen once. - */ - isc_once_do(&once, dlz_initialize); - /* lock the dlz_implementations list so we can modify it. */ RWLOCK(&dlz_implock, isc_rwlocktype_write); @@ -372,12 +365,6 @@ dns_dlzunregister(dns_dlzimplementation_t **dlzimp) { */ REQUIRE(dlzimp != NULL && *dlzimp != NULL); - /* - * initialize the dlz_implementations list, this is guaranteed - * to only really happen once. - */ - isc_once_do(&once, dlz_initialize); - dlz_imp = *dlzimp; /* lock the dlz_implementations list so we can modify it. */ diff --git a/lib/dns/dlz_p.h b/lib/dns/dlz_p.h new file mode 100644 index 00000000000..030aa5d6248 --- /dev/null +++ b/lib/dns/dlz_p.h @@ -0,0 +1,21 @@ +/* + * Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * SPDX-License-Identifier: MPL-2.0 + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, you can obtain one at https://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + +#pragma once + +/*! \file */ + +void +dns__dlz_initialize(void); +void +dns__dlz_shutdown(void); diff --git a/lib/dns/dst_api.c b/lib/dns/dst_api.c index 4db3ea29013..59209873376 100644 --- a/lib/dns/dst_api.c +++ b/lib/dns/dst_api.c @@ -190,12 +190,7 @@ addsuffix(char *filename, int len, const char *dirname, const char *ofilename, static isc_mem_t *dst__mctx = NULL; void -dst__lib_init(void) ISC_CONSTRUCTOR; -void -dst__lib_destroy(void) ISC_DESTRUCTOR; - -void -dst__lib_init(void) { +dst__lib_initialize(void) { isc_mem_create(&dst__mctx); dst__hmacmd5_init(&dst_t_func[DST_ALG_HMACMD5]); @@ -224,7 +219,7 @@ dst__lib_init(void) { } void -dst__lib_destroy(void) { +dst__lib_shutdown(void) { for (size_t i = 0; i < DST_MAX_ALGS; i++) { if (dst_t_func[i] != NULL && dst_t_func[i]->cleanup != NULL) { dst_t_func[i]->cleanup(); diff --git a/lib/dns/dst_internal.h b/lib/dns/dst_internal.h index cc57468f4f8..731d4b86027 100644 --- a/lib/dns/dst_internal.h +++ b/lib/dns/dst_internal.h @@ -224,4 +224,12 @@ dst_key_close(char *tmpname, FILE *fp, char *filename); isc_result_t dst_key_cleanup(char *tmpname, FILE *fp); +/*% + * Library constructor and destructor. + */ +void +dst__lib_initialize(void); +void +dst__lib_shutdown(void); + /*! \file */ diff --git a/lib/dns/dyndb.c b/lib/dns/dyndb.c index 6535c1d045b..b4ead8dcfa1 100644 --- a/lib/dns/dyndb.c +++ b/lib/dns/dyndb.c @@ -11,13 +11,10 @@ * information regarding copyright ownership. */ -#include - #include #include #include #include -#include #include #include #include @@ -29,6 +26,8 @@ #include #include +#include "dyndb_p.h" + #define CHECK(op) \ do { \ result = (op); \ @@ -57,14 +56,18 @@ static LIST(dyndb_implementation_t) dyndb_implementations; /* Locks dyndb_implementations. */ static isc_mutex_t dyndb_lock; -static isc_once_t once = ISC_ONCE_INIT; -static void -dyndb_initialize(void) { +void +dns__dyndb_initialize(void) { isc_mutex_init(&dyndb_lock); INIT_LIST(dyndb_implementations); } +void +dns__dyndb_shutdown(void) { + isc_mutex_destroy(&dyndb_lock); +} + static dyndb_implementation_t * impfind(const char *name) { dyndb_implementation_t *imp; @@ -211,8 +214,6 @@ dns_dyndb_load(const char *libname, const char *name, const char *parameters, REQUIRE(DNS_DYNDBCTX_VALID(dctx)); REQUIRE(name != NULL); - isc_once_do(&once, dyndb_initialize); - LOCK(&dyndb_lock); /* duplicate instance names are not allowed */ @@ -239,12 +240,10 @@ cleanup: } void -dns_dyndb_cleanup(bool exiting) { +dns_dyndb_cleanup(void) { dyndb_implementation_t *elem; dyndb_implementation_t *prev; - isc_once_do(&once, dyndb_initialize); - LOCK(&dyndb_lock); elem = TAIL(dyndb_implementations); while (elem != NULL) { @@ -259,10 +258,6 @@ dns_dyndb_cleanup(bool exiting) { elem = prev; } UNLOCK(&dyndb_lock); - - if (exiting) { - isc_mutex_destroy(&dyndb_lock); - } } void diff --git a/lib/dns/dyndb_p.h b/lib/dns/dyndb_p.h new file mode 100644 index 00000000000..09bd7dbd349 --- /dev/null +++ b/lib/dns/dyndb_p.h @@ -0,0 +1,21 @@ +/* + * Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * SPDX-License-Identifier: MPL-2.0 + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, you can obtain one at https://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + +#pragma once + +/*! \file */ + +void +dns__dyndb_initialize(void); +void +dns__dyndb_shutdown(void); diff --git a/lib/dns/include/dns/dyndb.h b/lib/dns/include/dns/dyndb.h index a54f710533c..fe90baf1771 100644 --- a/lib/dns/include/dns/dyndb.h +++ b/lib/dns/include/dns/dyndb.h @@ -117,12 +117,9 @@ dns_dyndb_load(const char *libname, const char *name, const char *parameters, */ void -dns_dyndb_cleanup(bool exiting); +dns_dyndb_cleanup(void); /*% * Shut down and destroy all running dyndb modules. - * - * 'exiting' indicates whether the server is shutting down, - * as opposed to merely being reconfigured. */ void diff --git a/lib/dns/include/dns/lib.h b/lib/dns/include/dns/lib.h new file mode 100644 index 00000000000..cb88744bbeb --- /dev/null +++ b/lib/dns/include/dns/lib.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * SPDX-License-Identifier: MPL-2.0 + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, you can obtain one at https://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + +#pragma once + +#include + +#include +#include + +void +dns__lib_initialize(void); +void +dns__lib_shutdown(void); + +void +dns_lib_initialize(void) __attribute__((__constructor__)); +void +dns_lib_shutdown(void) __attribute__((__destructor__)); + +void +dns_lib_initialize(void) { + isc__lib_initialize(); + dns__lib_initialize(); +} +void +dns_lib_shutdown(void) { + dns__lib_shutdown(); + isc__lib_shutdown(); +} diff --git a/lib/dns/include/dst/dst.h b/lib/dns/include/dst/dst.h index 5eb60380595..4bcb026b1c1 100644 --- a/lib/dns/include/dst/dst.h +++ b/lib/dns/include/dst/dst.h @@ -1226,7 +1226,7 @@ dst_key_setdirectory(dst_key_t *key, const char *dir); const char * dst_hmac_algorithm_totext(dst_algorithm_t alg); -/*$< +/*%< * Return the name associtated with the HMAC algorithm 'alg' * or return "unknown". */ diff --git a/lib/dns/lib.c b/lib/dns/lib.c new file mode 100644 index 00000000000..4825e374873 --- /dev/null +++ b/lib/dns/lib.c @@ -0,0 +1,63 @@ +/* + * Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * SPDX-License-Identifier: MPL-2.0 + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, you can obtain one at https://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + +/*! \file */ + +#include +#include + +#include "acl_p.h" +#include "db_p.h" +#include "dlz_p.h" +#include "dst_internal.h" +#include "dyndb_p.h" +#include "qp_p.h" + +/*** + *** Functions + ***/ + +static isc_refcount_t dns__lib_references = 0; + +void +dns__lib_initialize(void); +void +dns__lib_shutdown(void); + +void +dns__lib_initialize(void) { + if (isc_refcount_increment0(&dns__lib_references) > 0) { + return; + } + + dst__lib_initialize(); + dns__acl_initialize(); + dns__dlz_initialize(); + dns__db_initialize(); + dns__dyndb_initialize(); + dns__qp_initialize(); +} + +void +dns__lib_shutdown(void) { + if (isc_refcount_decrement(&dns__lib_references) > 1) { + return; + } + + dns__qp_shutdown(); + dns__dyndb_shutdown(); + dns__db_shutdown(); + dns__dlz_shutdown(); + dns__acl_shutdown(); + dst__lib_shutdown(); +} diff --git a/lib/dns/qp.c b/lib/dns/qp.c index 888d8f5653a..f7f38afb25b 100644 --- a/lib/dns/qp.c +++ b/lib/dns/qp.c @@ -135,8 +135,6 @@ uint8_t dns_qp_byte_for_bit[SHIFT_OFFSET] = { 0 }; * Fill in the lookup tables at program startup. (It doesn't matter * when this is initialized relative to other startup code.) */ -static void -initialize_bits_for_byte(void) ISC_CONSTRUCTOR; /* * The bit positions for bytes inside labels have to be between @@ -153,8 +151,8 @@ initialize_bits_for_byte(void) ISC_CONSTRUCTOR; * After filling the table we ensure that the bit positions for * hostname characters and escape characters all fit. */ -static void -initialize_bits_for_byte(void) { +void +dns__qp_initialize(void) { /* zero common character marker not a valid shift position */ INSIST(0 < SHIFT_BITMAP); /* first bit is common byte or escape byte */ @@ -193,6 +191,11 @@ initialize_bits_for_byte(void) { ENSURE(bit_one < SHIFT_OFFSET); } +void +dns__qp_shutdown(void) { + /* Nothing */ +} + /* * Convert a DNS name into a trie lookup key. * diff --git a/lib/dns/qp_p.h b/lib/dns/qp_p.h index d7c65131e72..0206c5fd56b 100644 --- a/lib/dns/qp_p.h +++ b/lib/dns/qp_p.h @@ -19,6 +19,8 @@ #pragma once +#include + /*********************************************************************** * * interior node basics @@ -925,3 +927,8 @@ extern uint16_t dns_qp_bits_for_byte[]; extern uint8_t dns_qp_byte_for_bit[]; /**********************************************************************/ + +void +dns__qp_initialize(void); +void +dns__qp_shutdown(void); diff --git a/lib/dns/rdata/in_1/wks_11.c b/lib/dns/rdata/in_1/wks_11.c index 4d6f22db9a1..23eb3b032a7 100644 --- a/lib/dns/rdata/in_1/wks_11.c +++ b/lib/dns/rdata/in_1/wks_11.c @@ -58,7 +58,7 @@ mygetservbyname(const char *name, const char *proto, long *port) { static isc_result_t fromtext_in_wks(ARGS_FROMTEXT) { - static isc_once_t once = ISC_ONCE_INIT; + static isc_once_t once = ISC_ONCE_INITIALIZER; isc_token_t token; isc_region_t region; struct in_addr addr; diff --git a/lib/isc/Makefile.am b/lib/isc/Makefile.am index d60ccd03b16..7cdca91b475 100644 --- a/lib/isc/Makefile.am +++ b/lib/isc/Makefile.am @@ -42,6 +42,7 @@ libisc_la_HEADERS = \ include/isc/iterated_hash.h \ include/isc/job.h \ include/isc/lex.h \ + include/isc/lib.h \ include/isc/list.h \ include/isc/log.h \ include/isc/loop.h \ diff --git a/lib/isc/include/isc/lib.h b/lib/isc/include/isc/lib.h new file mode 100644 index 00000000000..ee918e7899a --- /dev/null +++ b/lib/isc/include/isc/lib.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * SPDX-License-Identifier: MPL-2.0 + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, you can obtain one at https://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + +#pragma once + +#include + +void +isc__lib_initialize(void); +void +isc__lib_shutdown(void); + +void +isc_lib_initialize(void) __attribute__((__constructor__)); +void +isc_lib_shutdown(void) __attribute__((__destructor__)); + +void +isc_lib_initialize(void) { + isc__lib_initialize(); +} + +void +isc_lib_shutdown(void) { + isc__lib_shutdown(); +} diff --git a/lib/isc/include/isc/once.h b/lib/isc/include/isc/once.h index 4771b5cb5ea..d5cb73f2d76 100644 --- a/lib/isc/include/isc/once.h +++ b/lib/isc/include/isc/once.h @@ -21,7 +21,7 @@ typedef pthread_once_t isc_once_t; -#define ISC_ONCE_INIT PTHREAD_ONCE_INIT +#define ISC_ONCE_INITIALIZER PTHREAD_ONCE_INIT #define isc_once_do(op, f) \ { \ diff --git a/lib/isc/include/isc/util.h b/lib/isc/include/isc/util.h index 5eec716ea26..6d0b537c0e2 100644 --- a/lib/isc/include/isc/util.h +++ b/lib/isc/include/isc/util.h @@ -61,14 +61,6 @@ #define ISC_NONSTRING #endif /* __GNUC__ */ -#if HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR && HAVE_FUNC_ATTRIBUTE_DESTRUCTOR -#define ISC_CONSTRUCTOR __attribute__((constructor)) -#define ISC_DESTRUCTOR __attribute__((destructor)) -#else -#define ISC_CONSTRUCTOR -#define ISC_DESTRUCTOR -#endif - /*% * The opposite: silent warnings about stored values which are never read. */ diff --git a/lib/isc/lib.c b/lib/isc/lib.c index 9f1c6492df7..4553f4a3b50 100644 --- a/lib/isc/lib.c +++ b/lib/isc/lib.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -29,21 +30,24 @@ #include "mutex_p.h" #include "os_p.h" -#ifndef ISC_CONSTRUCTOR -#error Either __attribute__((constructor|destructor))__ or DllMain support needed to compile BIND 9. -#endif - /*** *** Functions ***/ +static isc_refcount_t isc__lib_references = 0; + void -isc__initialize(void) ISC_CONSTRUCTOR; +isc__lib_initialize(void); void -isc__shutdown(void) ISC_DESTRUCTOR; +isc__lib_shutdown(void); void -isc__initialize(void) { +isc__lib_initialize(void) { + if (isc_refcount_increment0(&isc__lib_references) > 0) { + return; + } + + rcu_register_thread(); isc__os_initialize(); isc__mutex_initialize(); isc__mem_initialize(); @@ -54,11 +58,14 @@ isc__initialize(void) { isc__hash_initialize(); isc__iterated_hash_initialize(); (void)isc_os_ncpus(); - rcu_register_thread(); } void -isc__shutdown(void) { +isc__lib_shutdown(void) { + if (isc_refcount_decrement(&isc__lib_references) > 1) { + return; + } + isc__iterated_hash_shutdown(); isc__xml_shutdown(); isc__uv_shutdown(); diff --git a/lib/isc/mem.c b/lib/isc/mem.c index 8a23b0f46ad..2651c503aba 100644 --- a/lib/isc/mem.c +++ b/lib/isc/mem.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -112,8 +111,6 @@ struct element { static ISC_LIST(isc_mem_t) contexts; -static isc_once_t init_once = ISC_ONCE_INIT; -static isc_once_t shut_once = ISC_ONCE_INIT; static isc_mutex_t contextslock; struct isc_mem { @@ -413,8 +410,8 @@ mem_jemalloc_arena_destroy(unsigned int arenano) { #endif /* JEMALLOC_API_SUPPORTED */ } -static void -mem_initialize(void) { +void +isc__mem_initialize(void) { /* * Check if the values copied from jemalloc still match */ @@ -427,12 +424,7 @@ mem_initialize(void) { } void -isc__mem_initialize(void) { - isc_once_do(&init_once, mem_initialize); -} - -static void -mem_shutdown(void) { +isc__mem_shutdown(void) { bool empty; isc__mem_checkdestroyed(); @@ -446,11 +438,6 @@ mem_shutdown(void) { } } -void -isc__mem_shutdown(void) { - isc_once_do(&shut_once, mem_shutdown); -} - static void mem_create(isc_mem_t **ctxp, unsigned int debugging, unsigned int flags, unsigned int jemalloc_flags) { diff --git a/lib/isc/mutex.c b/lib/isc/mutex.c index e31ba1339cc..ad1c4ce2cc6 100644 --- a/lib/isc/mutex.c +++ b/lib/isc/mutex.c @@ -28,10 +28,9 @@ #include "mutex_p.h" pthread_mutexattr_t isc__mutex_init_attr; -static isc_once_t init_once = ISC_ONCE_INIT; -static void -mutex_initialize(void) { +void +isc__mutex_initialize(void) { RUNTIME_CHECK(pthread_mutexattr_init(&isc__mutex_init_attr) == 0); #if ISC_MUTEX_ERROR_CHECK RUNTIME_CHECK(pthread_mutexattr_settype(&isc__mutex_init_attr, @@ -43,11 +42,6 @@ mutex_initialize(void) { #endif } -void -isc__mutex_initialize(void) { - isc_once_do(&init_once, mutex_initialize); -} - void isc__mutex_shutdown(void) { /* noop */; diff --git a/tests/bench/ascii.c b/tests/bench/ascii.c index e2123cb294f..4379e846c26 100644 --- a/tests/bench/ascii.c +++ b/tests/bench/ascii.c @@ -17,9 +17,12 @@ #include #include +#include #include #include +#include + #define SIZE (1024 * 1024) typedef void diff --git a/tests/bench/compress.c b/tests/bench/compress.c index 0df6abd22df..0660785ddc5 100644 --- a/tests/bench/compress.c +++ b/tests/bench/compress.c @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -25,6 +26,7 @@ #include #include +#include #include static void diff --git a/tests/bench/dns_name_fromwire.c b/tests/bench/dns_name_fromwire.c index a1d25b156a7..ef7d3936614 100644 --- a/tests/bench/dns_name_fromwire.c +++ b/tests/bench/dns_name_fromwire.c @@ -17,12 +17,14 @@ #include #include +#include #include #include #include #include #include +#include #include #include "old.h" diff --git a/tests/bench/iterated_hash.c b/tests/bench/iterated_hash.c index 7d11c93a4cf..1cc5755e8fb 100644 --- a/tests/bench/iterated_hash.c +++ b/tests/bench/iterated_hash.c @@ -17,9 +17,11 @@ #include #include +#include #include #include +#include #include static void diff --git a/tests/bench/load-names.c b/tests/bench/load-names.c index b4790961b74..86772841ad2 100644 --- a/tests/bench/load-names.c +++ b/tests/bench/load-names.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -26,6 +27,7 @@ #include #include +#include #include #include diff --git a/tests/bench/qp-dump.c b/tests/bench/qp-dump.c index 795fb3a662e..5356511a132 100644 --- a/tests/bench/qp-dump.c +++ b/tests/bench/qp-dump.c @@ -17,10 +17,12 @@ #include #include #include +#include #include #include #include +#include #include #include diff --git a/tests/bench/qplookups.c b/tests/bench/qplookups.c index fd478f3e6fa..12421c22f8f 100644 --- a/tests/bench/qplookups.c +++ b/tests/bench/qplookups.c @@ -17,11 +17,13 @@ #include #include #include +#include #include #include #include #include +#include #include #include diff --git a/tests/bench/qpmulti.c b/tests/bench/qpmulti.c index ec4d3e4244a..13aded4098a 100644 --- a/tests/bench/qpmulti.c +++ b/tests/bench/qpmulti.c @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -37,6 +38,7 @@ #include #include +#include #include #include diff --git a/tests/bench/siphash.c b/tests/bench/siphash.c index 8c1238537b5..c6a6f4d88b2 100644 --- a/tests/bench/siphash.c +++ b/tests/bench/siphash.c @@ -17,6 +17,7 @@ #include #include +#include #include #include #include diff --git a/tests/dns/acl_test.c b/tests/dns/acl_test.c index 443dd62748d..85a08b0c23b 100644 --- a/tests/dns/acl_test.c +++ b/tests/dns/acl_test.c @@ -24,10 +24,12 @@ #define UNIT_TESTING #include +#include #include #include #include +#include #include diff --git a/tests/dns/badcache_test.c b/tests/dns/badcache_test.c index 2e2695b0b7c..07baa49e903 100644 --- a/tests/dns/badcache_test.c +++ b/tests/dns/badcache_test.c @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -38,6 +39,7 @@ #include #include #include +#include #include #include diff --git a/tests/dns/db_test.c b/tests/dns/db_test.c index f3be8a66145..d9b7a1047a8 100644 --- a/tests/dns/db_test.c +++ b/tests/dns/db_test.c @@ -22,9 +22,12 @@ #define UNIT_TESTING #include +#include + #include #include #include +#include #include #include diff --git a/tests/dns/dbdiff_test.c b/tests/dns/dbdiff_test.c index f0fb8804f82..3c3f7ddd90e 100644 --- a/tests/dns/dbdiff_test.c +++ b/tests/dns/dbdiff_test.c @@ -23,11 +23,13 @@ #define UNIT_TESTING #include +#include #include #include #include #include +#include #include #include diff --git a/tests/dns/dbiterator_test.c b/tests/dns/dbiterator_test.c index 30980700b9d..67e19c71e55 100644 --- a/tests/dns/dbiterator_test.c +++ b/tests/dns/dbiterator_test.c @@ -23,10 +23,12 @@ #define UNIT_TESTING #include +#include #include #include #include +#include #include #include diff --git a/tests/dns/dbversion_test.c b/tests/dns/dbversion_test.c index 690cca80366..4ec3063f048 100644 --- a/tests/dns/dbversion_test.c +++ b/tests/dns/dbversion_test.c @@ -24,6 +24,7 @@ #include #include +#include #include #include #include @@ -31,6 +32,7 @@ #include #include +#include #include #include #include diff --git a/tests/dns/diff_test.c b/tests/dns/diff_test.c index 66d6d9b0154..ec93bb8c29b 100644 --- a/tests/dns/diff_test.c +++ b/tests/dns/diff_test.c @@ -24,7 +24,10 @@ #define UNIT_TESTING #include +#include + #include +#include #include diff --git a/tests/dns/dispatch_test.c b/tests/dns/dispatch_test.c index 20530e9e913..7eecbc8bac7 100644 --- a/tests/dns/dispatch_test.c +++ b/tests/dns/dispatch_test.c @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -32,6 +33,7 @@ #include #include +#include #include #include diff --git a/tests/dns/dns64_test.c b/tests/dns/dns64_test.c index ad547ae060b..82b92c65172 100644 --- a/tests/dns/dns64_test.c +++ b/tests/dns/dns64_test.c @@ -23,12 +23,14 @@ #define UNIT_TESTING #include +#include #include #include #include #include #include +#include #include #include #include diff --git a/tests/dns/dnstap_test.c b/tests/dns/dnstap_test.c index 45bdf2005fd..a7156b7ba94 100644 --- a/tests/dns/dnstap_test.c +++ b/tests/dns/dnstap_test.c @@ -28,11 +28,13 @@ #include #include +#include #include #include #include #include +#include #include #include diff --git a/tests/dns/dst_test.c b/tests/dns/dst_test.c index 2121e3883ec..871a4931ce5 100644 --- a/tests/dns/dst_test.c +++ b/tests/dns/dst_test.c @@ -33,11 +33,14 @@ #include #include #include +#include #include #include #include #include +#include + #include #include "dst_internal.h" diff --git a/tests/dns/ede_test.c b/tests/dns/ede_test.c index 76761cfb8fb..bbfad7d8440 100644 --- a/tests/dns/ede_test.c +++ b/tests/dns/ede_test.c @@ -24,9 +24,11 @@ #define UNIT_TESTING #include +#include #include #include +#include #include "../../lib/dns/ede.c" diff --git a/tests/dns/geoip_test.c b/tests/dns/geoip_test.c index 89a7fc6e30c..defca69c8fb 100644 --- a/tests/dns/geoip_test.c +++ b/tests/dns/geoip_test.c @@ -26,11 +26,13 @@ #include #include +#include #include #include #include #include +#include #include "geoip2.c" diff --git a/tests/dns/keytable_test.c b/tests/dns/keytable_test.c index 581e161b800..5b0ba19a3af 100644 --- a/tests/dns/keytable_test.c +++ b/tests/dns/keytable_test.c @@ -26,11 +26,13 @@ #include #include +#include #include #include #include #include +#include #include #include #include diff --git a/tests/dns/master_test.c b/tests/dns/master_test.c index 5c1a9bcc0be..0de8a9e02e7 100644 --- a/tests/dns/master_test.c +++ b/tests/dns/master_test.c @@ -25,12 +25,14 @@ #include #include +#include #include #include #include #include #include +#include #include #include #include diff --git a/tests/dns/name_test.c b/tests/dns/name_test.c index 4cb3b9cce72..8f159b9d278 100644 --- a/tests/dns/name_test.c +++ b/tests/dns/name_test.c @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -33,6 +34,7 @@ #include #include +#include #include #include diff --git a/tests/dns/nametree_test.c b/tests/dns/nametree_test.c index 71197ba345f..e0384d0c85c 100644 --- a/tests/dns/nametree_test.c +++ b/tests/dns/nametree_test.c @@ -26,10 +26,12 @@ #include #include +#include #include #include #include +#include #include #include diff --git a/tests/dns/nsec3_test.c b/tests/dns/nsec3_test.c index dd772d1cff2..957237e5cb3 100644 --- a/tests/dns/nsec3_test.c +++ b/tests/dns/nsec3_test.c @@ -23,10 +23,12 @@ #define UNIT_TESTING #include +#include #include #include #include +#include #include #include diff --git a/tests/dns/nsec3param_test.c b/tests/dns/nsec3param_test.c index 0892d931a36..35e3ce03430 100644 --- a/tests/dns/nsec3param_test.c +++ b/tests/dns/nsec3param_test.c @@ -24,11 +24,13 @@ #include #include +#include #include #include #include #include +#include #include #include "zone_p.h" diff --git a/tests/dns/private_test.c b/tests/dns/private_test.c index c40bd7f23cf..2bd8b366fb0 100644 --- a/tests/dns/private_test.c +++ b/tests/dns/private_test.c @@ -24,8 +24,10 @@ #include #include +#include #include +#include #include #include #include diff --git a/tests/dns/qp_test.c b/tests/dns/qp_test.c index f8c0954beef..8abfdd11fdc 100644 --- a/tests/dns/qp_test.c +++ b/tests/dns/qp_test.c @@ -23,6 +23,7 @@ #define UNIT_TESTING #include +#include #include #include #include @@ -30,6 +31,7 @@ #include #include +#include #include #include diff --git a/tests/dns/qpdb_test.c b/tests/dns/qpdb_test.c index 6adac9faca6..73931889dfc 100644 --- a/tests/dns/qpdb_test.c +++ b/tests/dns/qpdb_test.c @@ -23,8 +23,10 @@ #define UNIT_TESTING #include +#include #include +#include #include #include #include diff --git a/tests/dns/qpmulti_test.c b/tests/dns/qpmulti_test.c index 90d246ec7ad..11ff466e348 100644 --- a/tests/dns/qpmulti_test.c +++ b/tests/dns/qpmulti_test.c @@ -23,6 +23,7 @@ #include #include +#include #include #include #include @@ -33,6 +34,7 @@ #include #include +#include #include #include diff --git a/tests/dns/qpzone_test.c b/tests/dns/qpzone_test.c index 13a885016fd..e3c693d4a91 100644 --- a/tests/dns/qpzone_test.c +++ b/tests/dns/qpzone_test.c @@ -23,8 +23,10 @@ #define UNIT_TESTING #include +#include #include +#include #include #include #include diff --git a/tests/dns/rdata_test.c b/tests/dns/rdata_test.c index 85ed8056ed9..8a22fb9e4c4 100644 --- a/tests/dns/rdata_test.c +++ b/tests/dns/rdata_test.c @@ -30,10 +30,12 @@ #include #include #include +#include #include #include #include +#include #include #include "../isc/openssl_shim.c" diff --git a/tests/dns/rdataset_test.c b/tests/dns/rdataset_test.c index fc21b29f9d3..bd5674446ce 100644 --- a/tests/dns/rdataset_test.c +++ b/tests/dns/rdataset_test.c @@ -23,8 +23,10 @@ #define UNIT_TESTING #include +#include #include +#include #include #include diff --git a/tests/dns/rdatasetstats_test.c b/tests/dns/rdatasetstats_test.c index 8cfbebcc9ad..57acff6ac1c 100644 --- a/tests/dns/rdatasetstats_test.c +++ b/tests/dns/rdatasetstats_test.c @@ -24,8 +24,10 @@ #define UNIT_TESTING #include +#include #include +#include #include #include diff --git a/tests/dns/resconf_test.c b/tests/dns/resconf_test.c index dae666a6a5a..33e6aa8b47b 100644 --- a/tests/dns/resconf_test.c +++ b/tests/dns/resconf_test.c @@ -24,9 +24,12 @@ #define UNIT_TESTING #include +#include #include #include +#include + #include #include diff --git a/tests/dns/resolver_test.c b/tests/dns/resolver_test.c index 200c20e1c19..86c5931f784 100644 --- a/tests/dns/resolver_test.c +++ b/tests/dns/resolver_test.c @@ -23,12 +23,14 @@ #include #include +#include #include #include #include #include #include +#include #include #include #include diff --git a/tests/dns/rsa_test.c b/tests/dns/rsa_test.c index f634621943b..c1d44fa3f58 100644 --- a/tests/dns/rsa_test.c +++ b/tests/dns/rsa_test.c @@ -31,8 +31,11 @@ #define UNIT_TESTING #include +#include #include +#include + #include "dst_internal.h" #include diff --git a/tests/dns/sigs_test.c b/tests/dns/sigs_test.c index f5679d98320..277d4e9db7d 100644 --- a/tests/dns/sigs_test.c +++ b/tests/dns/sigs_test.c @@ -24,6 +24,7 @@ #include #include +#include #include #include #include @@ -35,6 +36,7 @@ #include #include #include +#include #include #include #include diff --git a/tests/dns/skr_test.c b/tests/dns/skr_test.c index c00baaa5ee5..a0038c6ddc0 100644 --- a/tests/dns/skr_test.c +++ b/tests/dns/skr_test.c @@ -26,12 +26,14 @@ #include #include #include +#include #include #include #include #include #include +#include #include #include #include diff --git a/tests/dns/time_test.c b/tests/dns/time_test.c index f6e19481f45..8002c0ed21e 100644 --- a/tests/dns/time_test.c +++ b/tests/dns/time_test.c @@ -23,8 +23,10 @@ #define UNIT_TESTING #include +#include #include +#include #include #include diff --git a/tests/dns/transport_test.c b/tests/dns/transport_test.c index 5bf07a149f8..e2186971d47 100644 --- a/tests/dns/transport_test.c +++ b/tests/dns/transport_test.c @@ -24,9 +24,11 @@ #define UNIT_TESTING #include +#include #include #include +#include #include #include diff --git a/tests/dns/tsig_test.c b/tests/dns/tsig_test.c index 5dd7a423b57..7a52f7d2f5e 100644 --- a/tests/dns/tsig_test.c +++ b/tests/dns/tsig_test.c @@ -23,11 +23,13 @@ #define UNIT_TESTING #include +#include #include #include #include #include +#include #include #include #include diff --git a/tests/dns/update_test.c b/tests/dns/update_test.c index 653f34ebbed..37cad328901 100644 --- a/tests/dns/update_test.c +++ b/tests/dns/update_test.c @@ -24,10 +24,12 @@ #define UNIT_TESTING #include +#include #include #include #include +#include #include #define KEEP_BEFORE diff --git a/tests/dns/zonemgr_test.c b/tests/dns/zonemgr_test.c index 0424e911d5b..fff8322482e 100644 --- a/tests/dns/zonemgr_test.c +++ b/tests/dns/zonemgr_test.c @@ -24,9 +24,11 @@ #include #include +#include #include #include +#include #include #include #include diff --git a/tests/dns/zt_test.c b/tests/dns/zt_test.c index 3e4dc37b066..eea991afd64 100644 --- a/tests/dns/zt_test.c +++ b/tests/dns/zt_test.c @@ -26,12 +26,14 @@ #include #include +#include #include #include #include #include #include +#include #include #include #include diff --git a/tests/isc/ascii_test.c b/tests/isc/ascii_test.c index f49b64b9e2f..141eae4c64d 100644 --- a/tests/isc/ascii_test.c +++ b/tests/isc/ascii_test.c @@ -22,6 +22,7 @@ #include #include +#include #include diff --git a/tests/isc/async_test.c b/tests/isc/async_test.c index bfc417362d6..ea8d5439194 100644 --- a/tests/isc/async_test.c +++ b/tests/isc/async_test.c @@ -26,6 +26,7 @@ #include #include +#include #include #include #include diff --git a/tests/isc/buffer_test.c b/tests/isc/buffer_test.c index fe6d2bcc276..3edc8dd1b24 100644 --- a/tests/isc/buffer_test.c +++ b/tests/isc/buffer_test.c @@ -27,6 +27,7 @@ #include #include +#include #include #include #include diff --git a/tests/isc/counter_test.c b/tests/isc/counter_test.c index 594d948f479..f9654e4e0cb 100644 --- a/tests/isc/counter_test.c +++ b/tests/isc/counter_test.c @@ -23,6 +23,7 @@ #include #include +#include #include #include diff --git a/tests/isc/dnsstream_utils_test.c b/tests/isc/dnsstream_utils_test.c index 68a0133eaed..d46c9727fe3 100644 --- a/tests/isc/dnsstream_utils_test.c +++ b/tests/isc/dnsstream_utils_test.c @@ -26,6 +26,7 @@ #include #include +#include #include #include #include diff --git a/tests/isc/doh_test.c b/tests/isc/doh_test.c index 339f4559d10..9ccc11f7771 100644 --- a/tests/isc/doh_test.c +++ b/tests/isc/doh_test.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include diff --git a/tests/isc/errno_test.c b/tests/isc/errno_test.c index fbfe56ad4e1..cdb44270b2a 100644 --- a/tests/isc/errno_test.c +++ b/tests/isc/errno_test.c @@ -24,6 +24,7 @@ #include #include +#include #include #include diff --git a/tests/isc/file_test.c b/tests/isc/file_test.c index 6b75ba24905..c569dbd9cdc 100644 --- a/tests/isc/file_test.c +++ b/tests/isc/file_test.c @@ -25,6 +25,7 @@ #include #include +#include #include #include diff --git a/tests/isc/hash_test.c b/tests/isc/hash_test.c index 6d04943866f..996d355cc7c 100644 --- a/tests/isc/hash_test.c +++ b/tests/isc/hash_test.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include diff --git a/tests/isc/hashmap_test.c b/tests/isc/hashmap_test.c index 7ff9327351b..c03a5724921 100644 --- a/tests/isc/hashmap_test.c +++ b/tests/isc/hashmap_test.c @@ -25,6 +25,7 @@ #include #include +#include #include #include #include diff --git a/tests/isc/heap_test.c b/tests/isc/heap_test.c index eba2b6b97aa..b6757c14b4a 100644 --- a/tests/isc/heap_test.c +++ b/tests/isc/heap_test.c @@ -25,6 +25,7 @@ #include #include +#include #include #include diff --git a/tests/isc/histo_test.c b/tests/isc/histo_test.c index 88c322f1601..ff586ca5997 100644 --- a/tests/isc/histo_test.c +++ b/tests/isc/histo_test.c @@ -26,6 +26,7 @@ #include #include +#include #include #include diff --git a/tests/isc/hmac_test.c b/tests/isc/hmac_test.c index 5784a8aec13..75c604b50d6 100644 --- a/tests/isc/hmac_test.c +++ b/tests/isc/hmac_test.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include diff --git a/tests/isc/ht_test.c b/tests/isc/ht_test.c index 2303def0089..40a6ef6c682 100644 --- a/tests/isc/ht_test.c +++ b/tests/isc/ht_test.c @@ -25,6 +25,7 @@ #include #include +#include #include #include #include diff --git a/tests/isc/job_test.c b/tests/isc/job_test.c index 6376bcc1353..9b5315575c4 100644 --- a/tests/isc/job_test.c +++ b/tests/isc/job_test.c @@ -26,6 +26,7 @@ #include #include +#include #include #include #include diff --git a/tests/isc/lex_test.c b/tests/isc/lex_test.c index ee0a0843419..ce35f382e6b 100644 --- a/tests/isc/lex_test.c +++ b/tests/isc/lex_test.c @@ -25,6 +25,7 @@ #include #include +#include #include #include diff --git a/tests/isc/loop_test.c b/tests/isc/loop_test.c index f7e1d28e8b3..b41c4f804d9 100644 --- a/tests/isc/loop_test.c +++ b/tests/isc/loop_test.c @@ -25,6 +25,7 @@ #include #include +#include #include #include #include diff --git a/tests/isc/md_test.c b/tests/isc/md_test.c index 69051b93c93..4ef72383df0 100644 --- a/tests/isc/md_test.c +++ b/tests/isc/md_test.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include diff --git a/tests/isc/mem_test.c b/tests/isc/mem_test.c index cdf25466568..ddb655440de 100644 --- a/tests/isc/mem_test.c +++ b/tests/isc/mem_test.c @@ -25,6 +25,7 @@ #include #include +#include #include #include #include diff --git a/tests/isc/mutex_test.c b/tests/isc/mutex_test.c index d45c694abab..7b4ca86a3c0 100644 --- a/tests/isc/mutex_test.c +++ b/tests/isc/mutex_test.c @@ -25,6 +25,7 @@ #include #include +#include #include #include #include diff --git a/tests/isc/netaddr_test.c b/tests/isc/netaddr_test.c index 2394e111666..3d2d2363bfa 100644 --- a/tests/isc/netaddr_test.c +++ b/tests/isc/netaddr_test.c @@ -24,6 +24,7 @@ #define UNIT_TESTING #include +#include #include #include #include diff --git a/tests/isc/parse_test.c b/tests/isc/parse_test.c index a5b516a0271..19e453b76f1 100644 --- a/tests/isc/parse_test.c +++ b/tests/isc/parse_test.c @@ -26,6 +26,7 @@ #define UNIT_TESTING #include +#include #include #include diff --git a/tests/isc/proxyheader_test.c b/tests/isc/proxyheader_test.c index 1f15dd63947..670dc4d2388 100644 --- a/tests/isc/proxyheader_test.c +++ b/tests/isc/proxyheader_test.c @@ -21,6 +21,7 @@ #include #include +#include #include #include #include diff --git a/tests/isc/proxystream_test.c b/tests/isc/proxystream_test.c index 295f63718c5..03fca07d8f8 100644 --- a/tests/isc/proxystream_test.c +++ b/tests/isc/proxystream_test.c @@ -28,6 +28,7 @@ #define UNIT_TESTING #include +#include #include #include #include diff --git a/tests/isc/proxyudp_test.c b/tests/isc/proxyudp_test.c index 2e5bcfce34b..9ebd499fb24 100644 --- a/tests/isc/proxyudp_test.c +++ b/tests/isc/proxyudp_test.c @@ -31,6 +31,7 @@ #include #include +#include #include #include #include diff --git a/tests/isc/quota_test.c b/tests/isc/quota_test.c index 1f802e06eef..6b9677978df 100644 --- a/tests/isc/quota_test.c +++ b/tests/isc/quota_test.c @@ -25,6 +25,7 @@ #include #include +#include #include #include #include diff --git a/tests/isc/radix_test.c b/tests/isc/radix_test.c index def5e9cf583..23671d1454d 100644 --- a/tests/isc/radix_test.c +++ b/tests/isc/radix_test.c @@ -22,6 +22,7 @@ #define UNIT_TESTING #include +#include #include #include #include diff --git a/tests/isc/random_test.c b/tests/isc/random_test.c index 21a33167d96..eb4ff1dcafc 100644 --- a/tests/isc/random_test.c +++ b/tests/isc/random_test.c @@ -31,6 +31,7 @@ #include #include +#include #include #include #include diff --git a/tests/isc/ratelimiter_test.c b/tests/isc/ratelimiter_test.c index 4183fb23a77..542d257ca30 100644 --- a/tests/isc/ratelimiter_test.c +++ b/tests/isc/ratelimiter_test.c @@ -24,6 +24,7 @@ #include #include +#include #include #include #include diff --git a/tests/isc/regex_test.c b/tests/isc/regex_test.c index 379dfdcc152..2cc4d9e8d9a 100644 --- a/tests/isc/regex_test.c +++ b/tests/isc/regex_test.c @@ -29,6 +29,7 @@ #include #include +#include #include #include diff --git a/tests/isc/result_test.c b/tests/isc/result_test.c index cec195bef4b..bc8f86b81ff 100644 --- a/tests/isc/result_test.c +++ b/tests/isc/result_test.c @@ -23,6 +23,7 @@ #define UNIT_TESTING #include +#include #include #include diff --git a/tests/isc/rwlock_test.c b/tests/isc/rwlock_test.c index dee4e382f32..74f9e4ca22a 100644 --- a/tests/isc/rwlock_test.c +++ b/tests/isc/rwlock_test.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include diff --git a/tests/isc/safe_test.c b/tests/isc/safe_test.c index a3f01fe9aff..d91b30cf0f5 100644 --- a/tests/isc/safe_test.c +++ b/tests/isc/safe_test.c @@ -24,6 +24,7 @@ #define UNIT_TESTING #include +#include #include #include diff --git a/tests/isc/siphash_test.c b/tests/isc/siphash_test.c index 6970ca98a79..9645c953ae1 100644 --- a/tests/isc/siphash_test.c +++ b/tests/isc/siphash_test.c @@ -22,6 +22,7 @@ #define UNIT_TESTING #include +#include #include #include diff --git a/tests/isc/sockaddr_test.c b/tests/isc/sockaddr_test.c index 4dd70602a8d..210efb0a872 100644 --- a/tests/isc/sockaddr_test.c +++ b/tests/isc/sockaddr_test.c @@ -24,6 +24,7 @@ #define UNIT_TESTING #include +#include #include #include #include diff --git a/tests/isc/spinlock_test.c b/tests/isc/spinlock_test.c index 89db2887741..273e33cebe4 100644 --- a/tests/isc/spinlock_test.c +++ b/tests/isc/spinlock_test.c @@ -23,6 +23,8 @@ #define UNIT_TESTING #include +#include + #ifdef HAVE_PTHREAD_SPIN_INIT #define HAD_PTHREAD_SPIN_INIT 1 #undef HAVE_PTHREAD_SPIN_INIT diff --git a/tests/isc/stats_test.c b/tests/isc/stats_test.c index 4bc541f33ce..8942f0d21ed 100644 --- a/tests/isc/stats_test.c +++ b/tests/isc/stats_test.c @@ -22,6 +22,7 @@ #define UNIT_TESTING #include +#include #include #include #include diff --git a/tests/isc/symtab_test.c b/tests/isc/symtab_test.c index 24da351bc84..87d7f58bc20 100644 --- a/tests/isc/symtab_test.c +++ b/tests/isc/symtab_test.c @@ -23,6 +23,7 @@ #define UNIT_TESTING #include +#include #include #include diff --git a/tests/isc/tcp_test.c b/tests/isc/tcp_test.c index 2538907e04a..05f9316ae35 100644 --- a/tests/isc/tcp_test.c +++ b/tests/isc/tcp_test.c @@ -29,6 +29,7 @@ #define UNIT_TESTING #include +#include #include #include #include diff --git a/tests/isc/tcpdns_test.c b/tests/isc/tcpdns_test.c index f2d3eed9dd1..b0d213f4bdc 100644 --- a/tests/isc/tcpdns_test.c +++ b/tests/isc/tcpdns_test.c @@ -30,6 +30,7 @@ #include #include +#include #include #include #include diff --git a/tests/isc/time_test.c b/tests/isc/time_test.c index 3b5113b8449..2bd85a636e3 100644 --- a/tests/isc/time_test.c +++ b/tests/isc/time_test.c @@ -23,6 +23,7 @@ #define UNIT_TESTING #include +#include #include #include #include diff --git a/tests/isc/timer_test.c b/tests/isc/timer_test.c index 66fbbc7d7ac..4a6ee8045cf 100644 --- a/tests/isc/timer_test.c +++ b/tests/isc/timer_test.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include diff --git a/tests/isc/tls_test.c b/tests/isc/tls_test.c index 425a7676511..9a4df5becda 100644 --- a/tests/isc/tls_test.c +++ b/tests/isc/tls_test.c @@ -29,6 +29,7 @@ #define UNIT_TESTING #include +#include #include #include #include diff --git a/tests/isc/tlsdns_test.c b/tests/isc/tlsdns_test.c index e8da5b04fd9..831c8c1d262 100644 --- a/tests/isc/tlsdns_test.c +++ b/tests/isc/tlsdns_test.c @@ -30,6 +30,7 @@ #include #include +#include #include #include #include diff --git a/tests/isc/udp_test.c b/tests/isc/udp_test.c index 610139b96a7..aaacd6d3835 100644 --- a/tests/isc/udp_test.c +++ b/tests/isc/udp_test.c @@ -31,6 +31,7 @@ #include #include +#include #include #include #include diff --git a/tests/isc/work_test.c b/tests/isc/work_test.c index 3c126ee613e..046cccb1b90 100644 --- a/tests/isc/work_test.c +++ b/tests/isc/work_test.c @@ -25,6 +25,7 @@ #include #include +#include #include #include #include diff --git a/tests/isccfg/duration_test.c b/tests/isccfg/duration_test.c index 660a278e485..8808b0d0856 100644 --- a/tests/isccfg/duration_test.c +++ b/tests/isccfg/duration_test.c @@ -26,6 +26,7 @@ #include #include +#include #include #include #include diff --git a/tests/isccfg/grammar_test.c b/tests/isccfg/grammar_test.c index e276287b594..d2424b2afe7 100644 --- a/tests/isccfg/grammar_test.c +++ b/tests/isccfg/grammar_test.c @@ -26,6 +26,7 @@ #include #include +#include #include #include #include diff --git a/tests/isccfg/parser_test.c b/tests/isccfg/parser_test.c index 403b3176db5..d7fdba0d862 100644 --- a/tests/isccfg/parser_test.c +++ b/tests/isccfg/parser_test.c @@ -26,6 +26,7 @@ #include #include +#include #include #include #include diff --git a/tests/ns/notify_test.c b/tests/ns/notify_test.c index 806470a6242..03d78c3abbf 100644 --- a/tests/ns/notify_test.c +++ b/tests/ns/notify_test.c @@ -24,10 +24,12 @@ #define UNIT_TESTING #include +#include #include #include #include +#include #include #include diff --git a/tests/ns/plugin_test.c b/tests/ns/plugin_test.c index 92b9b78b8d1..a7427c4c850 100644 --- a/tests/ns/plugin_test.c +++ b/tests/ns/plugin_test.c @@ -26,11 +26,14 @@ #include #include +#include #include #include #include #include +#include + #include #include diff --git a/tests/ns/query_test.c b/tests/ns/query_test.c index 812c23350d8..18801bc7429 100644 --- a/tests/ns/query_test.c +++ b/tests/ns/query_test.c @@ -23,10 +23,12 @@ #define UNIT_TESTING #include +#include #include #include #include +#include #include #include