]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Revert "Merge branch 'ondrej/fix-race-condition-in-dnstap-v9_11' into 'v9_11'"
authorEvan Hunt <each@isc.org>
Wed, 23 Jan 2019 18:56:26 +0000 (13:56 -0500)
committerEvan Hunt <each@isc.org>
Wed, 23 Jan 2019 18:56:26 +0000 (13:56 -0500)
This reverts merge request !1345

CHANGES
lib/dns/dnstap.c

diff --git a/CHANGES b/CHANGES
index a94c0afb86bbec67ff29c64bf1e0677c9372a4d2..06501b3b2d43efb6b74c95c25a7efdcedf9a2b9f 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -15,9 +15,6 @@
                        correctly and failed to add new lines between each
                        view. [GL !1327]
 
-5132.  [bug]           Fix race condition in cleanup part of dns_dt_create().
-                       [GL !1323]
-
 5128.  [bug]           Refreshkeytime was not being updated for managed
                        keys zones. [GL #784]
 
index d68a4eb1dd5ddad9fc165ba1dd30d75c81c2fe66..0c29d0ba78509fa6f0e7e90a08c5e7e993cdc3e5 100644 (file)
@@ -197,30 +197,26 @@ dns_dt_create(isc_mem_t *mctx, dns_dtmode_t mode, const char *path,
        generation++;
 
        env = isc_mem_get(mctx, sizeof(dns_dtenv_t));
+       if (env == NULL)
+               CHECK(ISC_R_NOMEMORY);
 
        memset(env, 0, sizeof(dns_dtenv_t));
 
-       env->magic = DTENV_MAGIC;
-       isc_mem_attach(mctx, &env->mctx);
-       env->reopen_task = reopen_task;
-       isc_mutex_init(&env->reopen_lock);
-       env->reopen_queued = false;
-       env->path = isc_mem_strdup(mctx, path);
-
        CHECK(isc_refcount_init(&env->refcount, 1));
        CHECK(isc_stats_create(mctx, &env->stats, dns_dnstapcounter_max));
+       env->path = isc_mem_strdup(mctx, path);
+       if (env->path == NULL)
+               CHECK(ISC_R_NOMEMORY);
 
        fwopt = fstrm_writer_options_init();
-       if (fwopt == NULL) {
+       if (fwopt == NULL)
                CHECK(ISC_R_NOMEMORY);
-       }
 
        res = fstrm_writer_options_add_content_type(fwopt,
                                            DNSTAP_CONTENT_TYPE,
                                            sizeof(DNSTAP_CONTENT_TYPE) - 1);
-       if (res != fstrm_res_success) {
+       if (res != fstrm_res_success)
                CHECK(ISC_R_FAILURE);
-       }
 
        if (mode == dns_dtmode_file) {
                ffwopt = fstrm_file_options_init();
@@ -235,13 +231,11 @@ dns_dt_create(isc_mem_t *mctx, dns_dtmode_t mode, const char *path,
                                                                  env->path);
                        fw = fstrm_unix_writer_init(fuwopt, fwopt);
                }
-       } else {
+       } else
                CHECK(ISC_R_FAILURE);
-       }
 
-       if (fw == NULL) {
+       if (fw == NULL)
                CHECK(ISC_R_FAILURE);
-       }
 
        env->iothr = fstrm_iothr_init(*foptp, &fw);
        if (env->iothr == NULL) {
@@ -255,6 +249,9 @@ dns_dt_create(isc_mem_t *mctx, dns_dtmode_t mode, const char *path,
        env->fopt = *foptp;
        *foptp = NULL;
 
+       isc_mem_attach(mctx, &env->mctx);
+
+       env->magic = DTENV_MAGIC;
        *envp = env;
 
  cleanup:
@@ -268,12 +265,15 @@ dns_dt_create(isc_mem_t *mctx, dns_dtmode_t mode, const char *path,
                fstrm_writer_options_destroy(&fwopt);
 
        if (result != ISC_R_SUCCESS) {
-               isc_mutex_destroy(&env->reopen_lock);
-               isc_mem_free(mctx, env->path);
-               if (env->stats != NULL) {
-                       isc_stats_detach(&env->stats);
+               if (env != NULL) {
+                       if (env->mctx != NULL)
+                               isc_mem_detach(&env->mctx);
+                       if (env->path != NULL)
+                               isc_mem_free(mctx, env->path);
+                       if (env->stats != NULL)
+                               isc_stats_detach(&env->stats);
+                       isc_mem_put(mctx, env, sizeof(dns_dtenv_t));
                }
-               isc_mem_putanddetach(&env->mctx, env, sizeof(dns_dtenv_t));
        }
 
        return (result);