]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Remove libdns init/shutdown functions
authorEvan Hunt <each@isc.org>
Wed, 15 Sep 2021 08:40:31 +0000 (01:40 -0700)
committerEvan Hunt <each@isc.org>
Mon, 4 Oct 2021 20:57:32 +0000 (13:57 -0700)
as libdns is no longer exported, it's not necessary to have
init and shutdown functions. the only purpose they served
was to create a private mctx and run dst_lib_init(), which
can be called directly instead.

15 files changed:
bin/delv/delv.c
bin/named/server.c
bin/tests/system/dyndb/driver/driver.c
bin/tests/system/resolve.c
lib/dns/Makefile.am
lib/dns/cache.c
lib/dns/db.c
lib/dns/include/dns/db.h
lib/dns/include/dns/lib.h [deleted file]
lib/dns/lib.c [deleted file]
lib/dns/masterdump.c
lib/dns/rbtdb.c
lib/dns/result.c
lib/dns/tests/result_test.c
util/copyrights

index 3559f1bf63e3518fcc28a0086e9e4d1b745d4110..960695cb89762dd997b3299ee577e1f337426c28 100644 (file)
@@ -47,7 +47,6 @@
 #include <dns/fixedname.h>
 #include <dns/keytable.h>
 #include <dns/keyvalues.h>
-#include <dns/lib.h>
 #include <dns/log.h>
 #include <dns/masterdump.h>
 #include <dns/name.h>
@@ -1735,13 +1734,15 @@ main(int argc, char *argv[]) {
        argc--;
        argv++;
 
-       result = dns_lib_init();
+       isc_mem_create(&mctx);
+
+       dns_result_register();
+
+       result = dst_lib_init(mctx, NULL);
        if (result != ISC_R_SUCCESS) {
-               fatal("dns_lib_init failed: %d", result);
+               fatal("dst_lib_init failed: %d", result);
        }
 
-       isc_mem_create(&mctx);
-
        CHECK(isc_appctx_create(mctx, &actx));
 
        isc_managers_create(mctx, 1, 0, 0, &netmgr, &taskmgr, &timermgr, NULL);
@@ -1856,7 +1857,7 @@ cleanup:
        }
        isc_mem_detach(&mctx);
 
-       dns_lib_shutdown();
+       dst_lib_destroy();
 
        return (0);
 }
index 31c9af55724bfa07c7e35bf618023587ee4e2bed..602afc089acb1895383802240d932ea1c4f18b02 100644 (file)
@@ -73,7 +73,6 @@
 #include <dns/keymgr.h>
 #include <dns/keytable.h>
 #include <dns/keyvalues.h>
-#include <dns/lib.h>
 #include <dns/master.h>
 #include <dns/masterdump.h>
 #include <dns/nsec3.h>
index 82b545d29cab38e5bd3f7594bc310d39adbf5a38..266e71476e6bb3bc9ab524a36efa63dd6e2e7943 100644 (file)
@@ -22,7 +22,6 @@
 
 #include <dns/db.h>
 #include <dns/dyndb.h>
-#include <dns/lib.h>
 #include <dns/types.h>
 
 #include "db.h"
index 6508b6e9fffe6c1b2577b2f4c9a80e00371767df..ee94fe98ad556f83dbc2942fd2cf4ea4a5b7d088 100644 (file)
@@ -37,7 +37,6 @@
 #include <dns/client.h>
 #include <dns/fixedname.h>
 #include <dns/keyvalues.h>
-#include <dns/lib.h>
 #include <dns/name.h>
 #include <dns/rdata.h>
 #include <dns/rdataset.h>
@@ -391,15 +390,15 @@ main(int argc, char *argv[]) {
                altserveraddr = cp + 1;
        }
 
-       result = dns_lib_init();
+       result = ctxs_init();
        if (result != ISC_R_SUCCESS) {
-               fprintf(stderr, "dns_lib_init failed: %u\n", result);
-               exit(1);
+               goto cleanup;
        }
 
-       result = ctxs_init();
+       result = dst_lib_init(ctxs_mctx, NULL);
        if (result != ISC_R_SUCCESS) {
-               goto cleanup;
+               fprintf(stderr, "dst_lib_init failed: %u\n", result);
+               exit(1);
        }
 
        clientopt = 0;
@@ -495,7 +494,7 @@ cleanup:
        }
 
        ctxs_destroy();
-       dns_lib_shutdown();
+       dst_lib_destroy();
 
        return (0);
 }
index d724dbd45bfc302daecd77049abfe92e4ca4c0b9..b763756b5e18fdf9e0979190e09552579d35e1b6 100644 (file)
@@ -87,7 +87,6 @@ libdns_la_HEADERS =                   \
        include/dns/keymgr.h            \
        include/dns/keytable.h          \
        include/dns/keyvalues.h         \
-       include/dns/lib.h               \
        include/dns/librpz.h            \
        include/dns/lookup.h            \
        include/dns/log.h               \
@@ -190,7 +189,6 @@ libdns_la_SOURCES =                 \
        keydata.c                       \
        keymgr.c                        \
        keytable.c                      \
-       lib.c                           \
        log.c                           \
        lookup.c                        \
        master.c                        \
index 579d3951310666669d263957fdccf9c00d223361..60de98f2bfc339ce63291ab5339c73019d8afcf1 100644 (file)
@@ -28,7 +28,6 @@
 #include <dns/db.h>
 #include <dns/dbiterator.h>
 #include <dns/events.h>
-#include <dns/lib.h>
 #include <dns/log.h>
 #include <dns/masterdump.h>
 #include <dns/rdata.h>
index c082a8d67794c5e20cb8130e8575551989bf466f..3a96f1d934fe9acc8f505ba4c923d3dc87a74ac8 100644 (file)
@@ -58,6 +58,8 @@ struct dns_dbimplementation {
 
 #include "rbtdb.h"
 
+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;
index 850746236e3039da08539fd359aa0e51ad03411c..29d3daebd23788bf65be17396ea18970fa0ceb66 100644 (file)
 
 ISC_LANG_BEGINDECLS
 
+/*%
+ * Tuning: external query load in packets per seconds.
+ */
+extern unsigned int dns_pps;
+
 /*****
 ***** Types
 *****/
diff --git a/lib/dns/include/dns/lib.h b/lib/dns/include/dns/lib.h
deleted file mode 100644 (file)
index 8ee94ec..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
- *
- * 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.
- */
-
-#ifndef DNS_LIB_H
-#define DNS_LIB_H 1
-
-/*! \file dns/lib.h */
-
-#include <isc/lang.h>
-#include <isc/types.h>
-
-ISC_LANG_BEGINDECLS
-
-/*%
- * Tuning: external query load in packets per seconds.
- */
-extern unsigned int dns_pps;
-
-isc_result_t
-dns_lib_init(void);
-/*%<
- * A set of initialization procedures used in the DNS library.  This function
- * is provided for an application that is not aware of the underlying ISC or
- * DNS libraries much.
- */
-
-void
-dns_lib_shutdown(void);
-/*%<
- * Free temporary resources allocated in dns_lib_init().
- */
-
-ISC_LANG_ENDDECLS
-
-#endif /* DNS_LIB_H */
diff --git a/lib/dns/lib.c b/lib/dns/lib.c
deleted file mode 100644 (file)
index 36d0f5b..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
- *
- * 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 <stdbool.h>
-#include <stddef.h>
-
-#include <isc/hash.h>
-#include <isc/mem.h>
-#include <isc/mutex.h>
-#include <isc/once.h>
-#include <isc/refcount.h>
-#include <isc/util.h>
-
-#include <dns/db.h>
-#include <dns/lib.h>
-#include <dns/result.h>
-
-#include <dst/dst.h>
-
-/***
- *** Globals
- ***/
-
-unsigned int dns_pps = 0U;
-
-/***
- *** Functions
- ***/
-
-static isc_once_t init_once = ISC_ONCE_INIT;
-static isc_mem_t *dns_g_mctx = NULL;
-static bool initialize_done = false;
-static isc_refcount_t references;
-
-static void
-initialize(void) {
-       isc_result_t result;
-
-       REQUIRE(!initialize_done);
-
-       isc_refcount_init(&references, 0);
-
-       isc_mem_create(&dns_g_mctx);
-       dns_result_register();
-
-       result = dst_lib_init(dns_g_mctx, NULL);
-       if (result != ISC_R_SUCCESS) {
-               goto cleanup_mctx;
-       }
-
-       initialize_done = true;
-       return;
-
-cleanup_mctx:
-       if (dns_g_mctx != NULL) {
-               isc_mem_detach(&dns_g_mctx);
-       }
-}
-
-isc_result_t
-dns_lib_init(void) {
-       isc_result_t result;
-
-       /*
-        * Since this routine is expected to be used by a normal application,
-        * it should be better to return an error, instead of an emergency
-        * abort, on any failure.
-        */
-       result = isc_once_do(&init_once, initialize);
-       if (result != ISC_R_SUCCESS) {
-               return (result);
-       }
-
-       if (!initialize_done) {
-               return (ISC_R_FAILURE);
-       }
-
-       isc_refcount_increment0(&references);
-
-       return (ISC_R_SUCCESS);
-}
-
-void
-dns_lib_shutdown(void) {
-       if (isc_refcount_decrement(&references) == 1) {
-               dst_lib_destroy();
-
-               isc_refcount_destroy(&references);
-
-               if (dns_g_mctx != NULL) {
-                       isc_mem_detach(&dns_g_mctx);
-               }
-       }
-}
index f3c0ebbbf5767bdebc6c0d604df72756a01cb712..f761376347194cf37e9ca33ef79729fdf660cd88 100644 (file)
@@ -34,7 +34,6 @@
 #include <dns/dbiterator.h>
 #include <dns/events.h>
 #include <dns/fixedname.h>
-#include <dns/lib.h>
 #include <dns/log.h>
 #include <dns/master.h>
 #include <dns/masterdump.h>
index ec803925b94306844210a6e75d59d846c3adcb43..97b8e6e8043764dabf58cada8b9f8692ec4852c7 100644 (file)
@@ -45,7 +45,6 @@
 #include <dns/dbiterator.h>
 #include <dns/events.h>
 #include <dns/fixedname.h>
-#include <dns/lib.h>
 #include <dns/log.h>
 #include <dns/masterdump.h>
 #include <dns/nsec.h>
index 01ce2b4e855333ba83c10b038730f4869ec7eef9..b037e7f6099049daec509a3f29ba7c4b6684dac0 100644 (file)
@@ -14,7 +14,6 @@
 #include <isc/once.h>
 #include <isc/util.h>
 
-#include <dns/lib.h>
 #include <dns/result.h>
 
 static const char *text[DNS_R_NRESULTS] = {
index b21828cbe5853d7b75f9b60a6d9aac0514db2029..66eeade0eca623cddc52474c2422a826b0ad4fab 100644 (file)
@@ -23,7 +23,6 @@
 #include <isc/result.h>
 #include <isc/util.h>
 
-#include <dns/lib.h>
 #include <dns/result.h>
 
 #include <dst/result.h>
index 42ce88bb7e6f98442f053c8887e92a4fdd50a014..13da1c293924e4906904a00a1a76645e3b0212fc 100644 (file)
 ./lib/dns/include/dns/keymgr.h                 C       2019,2020,2021
 ./lib/dns/include/dns/keytable.h               C       2000,2001,2004,2005,2007,2009,2010,2014,2015,2016,2017,2018,2019,2020,2021
 ./lib/dns/include/dns/keyvalues.h              C       1999,2000,2001,2003,2004,2005,2006,2007,2008,2009,2010,2012,2016,2017,2018,2019,2020,2021
-./lib/dns/include/dns/lib.h                    C       1999,2000,2001,2004,2005,2006,2007,2009,2016,2017,2018,2019,2020,2021
 ./lib/dns/include/dns/librpz.h                 C       2017,2018,2019,2020,2021
 ./lib/dns/include/dns/log.h                    C       1999,2000,2001,2003,2004,2005,2006,2007,2009,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021
 ./lib/dns/include/dns/lookup.h                 C       2000,2001,2004,2005,2006,2007,2009,2016,2018,2019,2020,2021
 ./lib/dns/keydata.c                            C       2009,2014,2016,2018,2019,2020,2021
 ./lib/dns/keymgr.c                             C       2019,2020,2021
 ./lib/dns/keytable.c                           C       2000,2001,2004,2005,2007,2009,2010,2013,2014,2015,2016,2017,2018,2019,2020,2021
-./lib/dns/lib.c                                        C       1999,2000,2001,2004,2005,2007,2009,2013,2014,2015,2016,2017,2018,2019,2020,2021
 ./lib/dns/log.c                                        C       1999,2000,2001,2003,2004,2005,2006,2007,2009,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021
 ./lib/dns/lookup.c                             C       2000,2001,2003,2004,2005,2007,2013,2016,2018,2019,2020,2021
 ./lib/dns/master.c                             C       1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021