2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 06:25:31 +00:00

Replace isc_log_create/destroy with isc_logconfig_get()

Add isc_logconfig_get() function to get the current logconfig and use
the getter to replace most of the little dancing around setting up
logging in the tools. Thus:

    isc_log_create(mctx, &lctx, &logconfig);
    isc_log_setcontext(lctx);
    dns_log_setcontext(lctx);
    ...
    ...use lcfg...
    ...
    isc_log_destroy();

is now only:

    logconfig = isc_logconfig_get(lctx);
    ...use lcfg...

For thread-safety, isc_logconfig_get() should be surrounded by RCU read
lock, but since we never use isc_logconfig_get() in threaded context,
the only place where it is actually used (but not really needed) is
named_log_init().
This commit is contained in:
Ondřej Surý
2024-08-13 15:52:51 +02:00
parent a8a689531f
commit b2dda86254
29 changed files with 60 additions and 234 deletions

View File

@@ -73,12 +73,10 @@ main(int argc, char **argv) {
isc_mem_create(&mctx);
isc_log_create(mctx, &lctx, &lcfg);
isc_log_setcontext(lctx);
/*
* Create and install the default channel.
*/
lcfg = isc_logconfig_get(lctx);
destination.file.stream = stderr;
destination.file.name = NULL;
destination.file.versions = ISC_LOG_ROLLNEVER;
@@ -176,7 +174,6 @@ main(int argc, char **argv) {
cfg_parser_destroy(&pctx);
}
isc_log_destroy(&lctx);
if (memstats) {
isc_mem_stats(mctx, stderr);
}