]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add dns_dt_create2()
authorMichał Kępień <michal@isc.org>
Mon, 5 Feb 2018 20:19:44 +0000 (21:19 +0100)
committerMichał Kępień <michal@isc.org>
Fri, 16 Feb 2018 08:37:23 +0000 (09:37 +0100)
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.

lib/dns/dnstap.c
lib/dns/include/dns/dnstap.h
lib/dns/win32/libdns.def.in

index 90227625440b8d1f144431050ae55d6414a116fa..37da38430387b72a2996972f719e6c98f7a9ce9a 100644 (file)
@@ -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;
index 9af1f3f2ff4d16ac23fb912e414d43638be2bfa3..b4002fc9a2694acaf6f6aa6016c8a91af30cc818 100644 (file)
@@ -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.
index cb7fbd40b79fcdcaace8fab7e5d519e9af17338e..7fb0db7a27d5a36a7e3429e0b73b0b357214b4ae 100644 (file)
@@ -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