diff --git a/doc/Changelog b/doc/Changelog index 6100d9a04..50175902e 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,3 +1,6 @@ +1 August 2019: Wouter + - For #52 #53, second context does not close logfile override. + 29 July 2019: Wouter - Add verbose log message when auth zone file is written, at level 4. - Add hex print of trust anchor pointer to trust anchor file temp diff --git a/libunbound/context.c b/libunbound/context.c index 20e3680ec..6d8b7b7b5 100644 --- a/libunbound/context.c +++ b/libunbound/context.c @@ -57,9 +57,16 @@ context_finalize(struct ub_ctx* ctx) { struct config_file* cfg = ctx->env->cfg; verbosity = cfg->verbosity; - if(ctx->logfile_override) + if(ctx_logfile_overridden) { + log_file(NULL); /* clear that override */ + ctx_logfile_overridden = 0; + } + if(ctx->logfile_override) { + ctx_logfile_overridden = 1; log_file(ctx->log_out); - else log_init(cfg->logfile, cfg->use_syslog, NULL); + } else { + log_init(cfg->logfile, cfg->use_syslog, NULL); + } config_apply(cfg); if(!modstack_setup(&ctx->mods, cfg->module_conf, ctx->env)) return UB_INITFAIL; diff --git a/libunbound/context.h b/libunbound/context.h index 11147226a..c3900154f 100644 --- a/libunbound/context.h +++ b/libunbound/context.h @@ -52,6 +52,9 @@ struct tube; struct sldns_buffer; struct ub_event_base; +/** store that the logfile has a debug override */ +extern int ctx_logfile_overridden; + /** * The context structure * diff --git a/libunbound/libunbound.c b/libunbound/libunbound.c index 9dd7d6dbe..b5f1137b8 100644 --- a/libunbound/libunbound.c +++ b/libunbound/libunbound.c @@ -79,6 +79,9 @@ #include #endif /* UB_ON_WINDOWS */ +/** store that the logfile has a debug override */ +int ctx_logfile_overridden = 0; + /** create context functionality, but no pipes */ static struct ub_ctx* ub_ctx_create_nopipe(void) { @@ -328,8 +331,10 @@ ub_ctx_delete(struct ub_ctx* ctx) ub_randfree(ctx->seed_rnd); alloc_clear(&ctx->superalloc); traverse_postorder(&ctx->queries, delq, NULL); - if(ctx->logfile_override) + if(ctx_logfile_overridden) { log_file(NULL); + ctx_logfile_overridden = 0; + } free(ctx); #ifdef USE_WINSOCK WSACleanup();