]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Remove support for external applications to register libisc
authorOndřej Surý <ondrej@sury.org>
Tue, 1 Oct 2019 07:47:19 +0000 (09:47 +0200)
committerOndřej Surý <ondrej@sury.org>
Mon, 30 Aug 2021 06:47:39 +0000 (08:47 +0200)
The previous versions of BIND 9 exported its internal libraries so that
they can be used by third-party applications more easily.  Certain
library functions were altered from specific BIND-only behavior to more
generic behavior when used by other applications.

This commit removes the function isc_lib_register() that was used by
external applications to enable the functionality.

15 files changed:
bin/delv/delv.c
bin/plugins/filter-a.c
bin/plugins/filter-aaaa.c
bin/tests/system/dyndb/driver/driver.c
bin/tests/system/hooks/driver/test-async.c
bin/tests/system/resolve.c
lib/dns/include/dns/dyndb.h
lib/isc/Makefile.am
lib/isc/app.c
lib/isc/bind9.c
lib/isc/include/isc/bind9.h
lib/isc/include/isc/lib.h [deleted file]
lib/isc/lib.c
lib/isc/result.c
util/copyrights

index c3ff1860b6da5db2b3dfea8d54bbb3a6a1a91582..aefe3b94dc11c44fac8533b724c80f53c70baba5 100644 (file)
@@ -28,7 +28,6 @@
 #include <isc/base64.h>
 #include <isc/buffer.h>
 #include <isc/hex.h>
-#include <isc/lib.h>
 #include <isc/log.h>
 #include <isc/managers.h>
 #include <isc/md.h>
@@ -1737,7 +1736,6 @@ main(int argc, char *argv[]) {
        argc--;
        argv++;
 
-       isc_lib_register();
        result = dns_lib_init();
        if (result != ISC_R_SUCCESS) {
                fatal("dns_lib_init failed: %d", result);
index 1c67a6cb669e6586246aeb3d0f7af14fc99c4407..f72d6e54ab14579e4bb566864424774d1e7c99a8 100644 (file)
@@ -20,7 +20,6 @@
 #include <isc/buffer.h>
 #include <isc/hash.h>
 #include <isc/ht.h>
-#include <isc/lib.h>
 #include <isc/log.h>
 #include <isc/mem.h>
 #include <isc/netaddr.h>
index a00946f5f802676050b27b872e89710d5e2e995a..ec741835b8633bb67916e2da2292b76bdb91de69 100644 (file)
@@ -20,7 +20,6 @@
 #include <isc/buffer.h>
 #include <isc/hash.h>
 #include <isc/ht.h>
-#include <isc/lib.h>
 #include <isc/log.h>
 #include <isc/mem.h>
 #include <isc/netaddr.h>
index 1af50c6c14ec47312a362e96de73e9d5c8bee1ce..82b545d29cab38e5bd3f7594bc310d39adbf5a38 100644 (file)
@@ -17,7 +17,6 @@
 
 #include <isc/commandline.h>
 #include <isc/hash.h>
-#include <isc/lib.h>
 #include <isc/mem.h>
 #include <isc/util.h>
 
@@ -76,7 +75,6 @@ dyndb_init(isc_mem_t *mctx, const char *name, const char *parameters,
         * to initialize libisc/libdns
         */
        if (dctx->refvar != &isc_bind9) {
-               isc_lib_register();
                isc_log_setcontext(dctx->lctx);
                dns_log_setcontext(dctx->lctx);
                isc_hash_set_initializer(dctx->hashinit);
index f3deee2b83794565303f2a01757a4e4cdc4373e5..d52f2eb688bdef0ff068ae0c4f14c1653bc4136f 100644 (file)
@@ -20,7 +20,6 @@
 #include <isc/buffer.h>
 #include <isc/hash.h>
 #include <isc/ht.h>
-#include <isc/lib.h>
 #include <isc/log.h>
 #include <isc/mem.h>
 #include <isc/netaddr.h>
index 165124a68ff67fbf23e9588a6b0df6592cc3cf84..cf95ffd9ce2800c9d76fb02748a25369682f5f05 100644 (file)
@@ -25,7 +25,6 @@
 #include <isc/base64.h>
 #include <isc/buffer.h>
 #include <isc/commandline.h>
-#include <isc/lib.h>
 #include <isc/managers.h>
 #include <isc/mem.h>
 #include <isc/print.h>
@@ -394,7 +393,6 @@ main(int argc, char *argv[]) {
                altserveraddr = cp + 1;
        }
 
-       isc_lib_register();
        result = dns_lib_init();
        if (result != ISC_R_SUCCESS) {
                fprintf(stderr, "dns_lib_init failed: %u\n", result);
index 2b0d1edbc0c913aeff494d368576dc87c2bf0fda..0b2625403c2d237956d9252b050f21e01f78a0e5 100644 (file)
@@ -40,7 +40,7 @@ struct dns_dyndbctx {
        dns_zonemgr_t * zmgr;
        isc_task_t *    task;
        isc_timermgr_t *timermgr;
-       bool *          refvar;
+       const bool *    refvar;
 };
 
 #define DNS_DYNDBCTX_MAGIC    ISC_MAGIC('D', 'd', 'b', 'c')
index 5f90634b3a11e98abe3fdf18cc0f337fe4523928..b6bd2a4dfd9588bf5a2407f9cc07925c895dd73c 100644 (file)
@@ -45,7 +45,6 @@ libisc_la_HEADERS =                   \
        include/isc/iterated_hash.h     \
        include/isc/lang.h              \
        include/isc/lex.h               \
-       include/isc/lib.h               \
        include/isc/likely.h            \
        include/isc/list.h              \
        include/isc/log.h               \
index 1efadd0241ee03af6e919cef194e3ad3ae918aa7..7bbb0331fe27ff13cca8bfd5216106648ca83d0d 100644 (file)
@@ -36,8 +36,8 @@
 #include <isc/util.h>
 
 /*%
- * For BIND9 internal applications built with threads, we use a single app
- * context and let multiple worker, I/O, timer threads do actual jobs.
+ * For BIND9 applications built with threads, we use a single app
+ * context and let multiple taskmgr and netmgr threads do actual jobs.
  */
 
 static isc_thread_t blockedthread;
@@ -206,13 +206,6 @@ isc_app_ctxrun(isc_appctx_t *ctx) {
                UNLOCK(&ctx->lock);
        }
 
-       /*
-        * BIND9 internal tools using multiple contexts do not
-        * rely on signal. */
-       if (isc_bind9 && ctx != &isc_g_appctx) {
-               return (ISC_R_SUCCESS);
-       }
-
        /*
         * There is no danger if isc_app_shutdown() is called before we
         * wait for signals.  Signals are blocked, so any such signal will
@@ -220,11 +213,10 @@ isc_app_ctxrun(isc_appctx_t *ctx) {
         * sigwait().
         */
        while (!atomic_load_acquire(&ctx->want_shutdown)) {
-               if (isc_bind9) {
+               if (ctx == &isc_g_appctx) {
                        sigset_t sset;
                        int sig;
                        /*
-                        * BIND9 internal; single context:
                         * Wait for SIGHUP, SIGINT, or SIGTERM.
                         */
                        if (sigemptyset(&sset) != 0 ||
@@ -257,8 +249,9 @@ isc_app_ctxrun(isc_appctx_t *ctx) {
                        }
                } else {
                        /*
-                        * External, or BIND9 using multiple contexts:
-                        * wait until woken up.
+                        * Tools using multiple contexts don't
+                        * rely on a signal, just wait until woken
+                        * up.
                         */
                        if (atomic_load_acquire(&ctx->want_shutdown)) {
                                break;
@@ -314,11 +307,12 @@ isc_app_ctxshutdown(isc_appctx_t *ctx) {
        if (atomic_compare_exchange_strong_acq_rel(&ctx->shutdown_requested,
                                                   &(bool){ false }, true))
        {
-               if (isc_bind9 && ctx != &isc_g_appctx) {
-                       /* BIND9 internal, but using multiple contexts */
+               if (ctx != &isc_g_appctx) {
+                       /* Tool using multiple contexts */
                        atomic_store_release(&ctx->want_shutdown, true);
-               } else if (isc_bind9) {
-                       /* BIND9 internal, single context */
+                       SIGNAL(&ctx->ready);
+               } else {
+                       /* Normal single BIND9 context */
                        if (kill(getpid(), SIGTERM) < 0) {
                                char strbuf[ISC_STRERRORSIZE];
                                strerror_r(errno, strbuf, sizeof(strbuf));
@@ -327,10 +321,6 @@ isc_app_ctxshutdown(isc_appctx_t *ctx) {
                                                "kill: %s",
                                                strbuf);
                        }
-               } else {
-                       /* External, multiple contexts */
-                       atomic_store_release(&ctx->want_shutdown, true);
-                       SIGNAL(&ctx->ready);
                }
        }
 }
@@ -350,11 +340,12 @@ isc_app_ctxsuspend(isc_appctx_t *ctx) {
         * Don't send the reload signal if we're shutting down.
         */
        if (!atomic_load_acquire(&ctx->shutdown_requested)) {
-               if (isc_bind9 && ctx != &isc_g_appctx) {
-                       /* BIND9 internal, but using multiple contexts */
+               if (ctx != &isc_g_appctx) {
+                       /* Tool using multiple contexts */
                        atomic_store_release(&ctx->want_reload, true);
-               } else if (isc_bind9) {
-                       /* BIND9 internal, single context */
+                       SIGNAL(&ctx->ready);
+               } else {
+                       /* Normal single BIND9 context */
                        if (kill(getpid(), SIGHUP) < 0) {
                                char strbuf[ISC_STRERRORSIZE];
                                strerror_r(errno, strbuf, sizeof(strbuf));
@@ -363,10 +354,6 @@ isc_app_ctxsuspend(isc_appctx_t *ctx) {
                                                "kill: %s",
                                                strbuf);
                        }
-               } else {
-                       /* External, multiple contexts */
-                       atomic_store_release(&ctx->want_reload, true);
-                       SIGNAL(&ctx->ready);
                }
        }
 }
index 9b7bdfacdae8aa5b444d78770030ba87d3280084..6bbe3f6a792cc7d85f9b6a57c1309099ac326ca7 100644 (file)
 
 #include <isc/bind9.h>
 
-/*
- * This determines whether we are using the libisc/libdns libraries
- * in BIND9 or in some other application. It is initialized to true
- * and remains unchanged for BIND9 and related tools; export library
- * clients will run isc_lib_register(), which sets it to false,
- * overriding certain BIND9 behaviors.
- */
 bool isc_bind9 = true;
index be5a7df3a1b97ea9db5f73b27b4fb26caa03f83a..edbdc946a978b7e475536877cf22e9a7a91244ac 100644 (file)
@@ -9,17 +9,8 @@
  * information regarding copyright ownership.
  */
 
-#ifndef ISC_BIND9_H
-#define ISC_BIND9_H 1
+#pragma once
 
 #include <stdbool.h>
 
-/*
- * This determines whether we are using the libisc/libdns libraries
- * in BIND9 or in some other application.  For BIND9 (named and related
- * tools) it must be set to true at runtime.  Export library clients
- * will call isc_lib_register(), which will set it to false.
- */
 extern bool isc_bind9;
-
-#endif /* ISC_BIND9_H */
diff --git a/lib/isc/include/isc/lib.h b/lib/isc/include/isc/lib.h
deleted file mode 100644 (file)
index 4a77293..0000000
+++ /dev/null
@@ -1,33 +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 ISC_LIB_H
-#define ISC_LIB_H 1
-
-/*! \file isc/lib.h */
-
-#include <isc/lang.h>
-#include <isc/types.h>
-
-ISC_LANG_BEGINDECLS
-
-void
-isc_lib_register(void);
-/*!<
- * \brief Register the ISC library implementations for some base services
- * such as memory or event management and handling socket or timer events.
- * An external application that wants to use the ISC library must call this
- * function very early in main().
- */
-
-ISC_LANG_ENDDECLS
-
-#endif /* ISC_LIB_H */
index 18e3284be072e974842eb5d54a9eb2188c7fe63d..5f9173ff4cb2c61aab0627364de9d3449b3f14e9 100644 (file)
@@ -12,7 +12,6 @@
 /*! \file */
 
 #include <isc/bind9.h>
-#include <isc/lib.h>
 #include <isc/mem.h>
 #include <isc/os.h>
 #include <isc/tls.h>
  *** Functions
  ***/
 
-void
-isc_lib_register(void) {
-       isc_bind9 = false;
-}
-
 void
 isc__initialize(void) ISC_CONSTRUCTOR;
 void
index 72e7a3c28e4f6dbf304118d9a4761ed13e0aaa2f..6a10dd1c2cc81e4558ed50031a1b5d48ff8eba1c 100644 (file)
@@ -14,7 +14,6 @@
 #include <stddef.h>
 #include <stdlib.h>
 
-#include <isc/lib.h>
 #include <isc/once.h>
 #include <isc/resultclass.h>
 #include <isc/rwlock.h>
index 490b788e8af8944257f7e1b4448f70aed74539c6..25f5077bc5d8599fe60d6d0bd1cbaeb9ddd8a670 100644 (file)
 ./lib/isc/include/isc/iterated_hash.h          C       2008,2014,2016,2018,2019,2020,2021
 ./lib/isc/include/isc/lang.h                   C       1999,2000,2001,2004,2005,2006,2007,2016,2018,2019,2020,2021
 ./lib/isc/include/isc/lex.h                    C       1998,1999,2000,2001,2002,2004,2005,2007,2008,2015,2016,2017,2018,2019,2020,2021
-./lib/isc/include/isc/lib.h                    C       1999,2000,2001,2004,2005,2006,2007,2009,2016,2018,2019,2020,2021
 ./lib/isc/include/isc/likely.h                 C       2017,2018,2019,2020,2021
 ./lib/isc/include/isc/list.h                   C       1997,1998,1999,2000,2001,2002,2004,2006,2007,2011,2012,2013,2016,2018,2019,2020,2021
 ./lib/isc/include/isc/log.h                    C       1999,2000,2001,2002,2004,2005,2006,2007,2009,2014,2016,2017,2018,2019,2020,2021