mirror of
https://github.com/isc-projects/bind9.git
synced 2026-03-01 21:10:55 -05:00
Remove support for external applications to register libisc
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.
This commit is contained in:
parent
5dd11a6aa4
commit
cdf9a1fd20
15 changed files with 18 additions and 98 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
|
|
|
|||
|
|
@ -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 \
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,11 +15,4 @@
|
|||
|
||||
#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;
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
@ -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>
|
||||
|
|
@ -31,11 +30,6 @@
|
|||
*** Functions
|
||||
***/
|
||||
|
||||
void
|
||||
isc_lib_register(void) {
|
||||
isc_bind9 = false;
|
||||
}
|
||||
|
||||
void
|
||||
isc__initialize(void) ISC_CONSTRUCTOR;
|
||||
void
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -1723,7 +1723,6 @@
|
|||
./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
|
||||
|
|
|
|||
Loading…
Reference in a new issue