diff --git a/bin/named/server.c b/bin/named/server.c index 3c17063a00..89cf2800b6 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -3549,8 +3549,9 @@ configure_dnstap(const cfg_obj_t **maps, dns_view_t *view) { fstrm_iothr_options_set_reopen_interval(fopt, i); } - CHECKM(dns_dt_create(named_g_mctx, dmode, dpath, - &fopt, &named_g_server->dtenv), + CHECKM(dns_dt_create2(named_g_mctx, dmode, dpath, + &fopt, named_g_server->task, + &named_g_server->dtenv), "unable to create dnstap environment"); CHECKM(dns_dt_setupfile(named_g_server->dtenv, @@ -14825,10 +14826,7 @@ named_server_dnstap(named_server_t *server, isc_lex_t *lex, return (DNS_R_SYNTAX); } - result = isc_task_beginexclusive(server->task); - RUNTIME_CHECK(result == ISC_R_SUCCESS); result = dns_dt_reopen(server->dtenv, backups); - isc_task_endexclusive(server->task); return (result); #else UNUSED(server); diff --git a/lib/dns/dnstap.c b/lib/dns/dnstap.c index 37da384303..6973a0b2d3 100644 --- a/lib/dns/dnstap.c +++ b/lib/dns/dnstap.c @@ -55,6 +55,7 @@ #include #include #include +#include #include #include #include @@ -331,11 +332,18 @@ dns_dt_reopen(dns_dtenv_t *env, int roll) { REQUIRE(VALID_DTENV(env)); + /* + * Run in task-exclusive mode. + */ + result = isc_task_beginexclusive(env->reopen_task); + RUNTIME_CHECK(result == ISC_R_SUCCESS); + /* * Check that we can create a new fw object. */ fwopt = fstrm_writer_options_init(); if (fwopt == NULL) { + isc_task_endexclusive(env->reopen_task); return (ISC_R_NOMEMORY); } @@ -424,6 +432,8 @@ dns_dt_reopen(dns_dtenv_t *env, int roll) { if (fuwopt != NULL) fstrm_unix_writer_options_destroy(&fuwopt); + isc_task_endexclusive(env->reopen_task); + return (result); } diff --git a/lib/dns/include/dns/dnstap.h b/lib/dns/include/dns/dnstap.h index b4002fc9a2..38e1e0449a 100644 --- a/lib/dns/include/dns/dnstap.h +++ b/lib/dns/include/dns/dnstap.h @@ -195,7 +195,8 @@ dns_dt_reopen(dns_dtenv_t *env, int roll); * keep. If 'roll' is negative, or if 'env->mode' is dns_dtmode_unix, * then the channel is simply reopened. * - * Note: dns_dt_reopen() must be called in task exclusive mode. + * Note: dns_dt_reopen() uses task-exclusive mode and must be run in the + * context of env->reopen_task. * * Requires: *\li 'env' is a valid dnstap environment.