From: Michał Kępień Date: Mon, 5 Feb 2018 20:19:44 +0000 (+0100) Subject: Add dns_dt_create2() X-Git-Tag: v9.12.1rc1~3^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e26c5df16f7b13b3bada4cb7a3e3ca10af688611;p=thirdparty%2Fbind9.git Add dns_dt_create2() Implement a new variant of dns_dt_create() to enable a dnstap environment structure to hold the task in the context of which dns_dt_reopen() will be executed. --- diff --git a/lib/dns/dnstap.c b/lib/dns/dnstap.c index 90227625440..37da3843038 100644 --- a/lib/dns/dnstap.c +++ b/lib/dns/dnstap.c @@ -101,6 +101,8 @@ struct dns_dtenv { struct fstrm_iothr *iothr; struct fstrm_iothr_options *fopt; + isc_task_t *reopen_task; + isc_region_t identity; isc_region_t version; char *path; @@ -176,6 +178,14 @@ unlock: isc_result_t dns_dt_create(isc_mem_t *mctx, dns_dtmode_t mode, const char *path, struct fstrm_iothr_options **foptp, dns_dtenv_t **envp) +{ + return (dns_dt_create2(mctx, mode, path, foptp, NULL, envp)); +} + +isc_result_t +dns_dt_create2(isc_mem_t *mctx, dns_dtmode_t mode, const char *path, + struct fstrm_iothr_options **foptp, isc_task_t *reopen_task, + dns_dtenv_t **envp) { isc_result_t result = ISC_R_SUCCESS; fstrm_res res; @@ -250,6 +260,8 @@ dns_dt_create(isc_mem_t *mctx, dns_dtmode_t mode, const char *path, env->fopt = *foptp; *foptp = NULL; + env->reopen_task = reopen_task; + isc_mem_attach(mctx, &env->mctx); env->magic = DTENV_MAGIC; diff --git a/lib/dns/include/dns/dnstap.h b/lib/dns/include/dns/dnstap.h index 9af1f3f2ff4..b4002fc9a26 100644 --- a/lib/dns/include/dns/dnstap.h +++ b/lib/dns/include/dns/dnstap.h @@ -116,6 +116,11 @@ struct dns_dtdata { isc_result_t dns_dt_create(isc_mem_t *mctx, dns_dtmode_t mode, const char *path, struct fstrm_iothr_options **foptp, dns_dtenv_t **envp); + +isc_result_t +dns_dt_create2(isc_mem_t *mctx, dns_dtmode_t mode, const char *path, + struct fstrm_iothr_options **foptp, isc_task_t *reopen_task, + dns_dtenv_t **envp); /*%< * Create and initialize the dnstap environment. * @@ -135,13 +140,18 @@ dns_dt_create(isc_mem_t *mctx, dns_dtmode_t mode, const char *path, * should also be set. Other options may be set if desired. * If dns_dt_create succeeds the *foptp is set to NULL. * + *\li 'reopen_task' needs to be set to the task in the context of which + * dns_dt_reopen() will be called. This is not an optional parameter: + * using dns_dt_create() (which sets 'reopen_task' to NULL) is only + * allowed in unit tests. + * * Requires: * *\li 'mctx' is a valid memory context. * *\li 'path' is a valid C string. * - *\li 'fopt' is non NULL. + *\li 'foptp' is non NULL. * *\li envp != NULL && *envp == NULL * @@ -177,7 +187,7 @@ dns_dt_setupfile(dns_dtenv_t *env, isc_uint64_t max_size, int rolls, isc_result_t dns_dt_reopen(dns_dtenv_t *env, int roll); /*%< - * Reopens files established by dns_dt_create(). + * Reopens files established by dns_dt_create2(). * * If 'roll' is non-negative and 'env->mode' is dns_dtmode_file, * then the file is automatically rolled over before reopening. diff --git a/lib/dns/win32/libdns.def.in b/lib/dns/win32/libdns.def.in index cb7fbd40b79..7fb0db7a27d 100644 --- a/lib/dns/win32/libdns.def.in +++ b/lib/dns/win32/libdns.def.in @@ -360,6 +360,7 @@ dns_dsdigest_totext dns_dt_attach dns_dt_close dns_dt_create +dns_dt_create2 dns_dt_datatotext dns_dt_detach dns_dt_getframe