Blob Blame History Raw
From 1f6c240231fcb9fe8bc4a28f3359201c2a1d8465 Mon Sep 17 00:00:00 2001
From: Tomas Hozza <thozza@redhat.com>
Date: Wed, 17 Sep 2014 20:00:39 +0200
Subject: [PATCH] Fix for BZ #1142150

Signed-off-by: Tomas Hozza <thozza@redhat.com>
---
 bin/named/server.c               | 14 +++++++++-----
 lib/dns/dynamic_db.c             | 12 ++++++++++--
 lib/dns/include/dns/dynamic_db.h |  2 +-
 3 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/bin/named/server.c b/bin/named/server.c
index ee04dda..6f8b0f0 100644
--- a/bin/named/server.c
+++ b/bin/named/server.c
@@ -1302,6 +1302,12 @@ configure_dynamic_db(const cfg_obj_t *dynamic_db, isc_mem_t *mctx,
 	CHECK(dns_dynamic_db_load(libname, name, mctx, argv, dyndb_args));
 
 cleanup:
+
+	if (result != ISC_R_SUCCESS)
+		isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
+		              NS_LOGMODULE_SERVER, ISC_LOG_ERROR,
+		              "dynamic database '%s' configuration failed: %s",
+		              name, isc_result_totext(result));
 	if (argv != NULL)
 		isc_mem_free(mctx, argv);
 
@@ -2165,6 +2171,7 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig,
 	unsigned int query_timeout, ndisp;
 	struct cfg_context *nzctx;
 	dns_rpz_zone_t *rpz;
+	dns_dyndb_arguments_t *args = NULL;
 
 	REQUIRE(DNS_VIEW_VALID(view));
 
@@ -3330,8 +3337,6 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig,
 		(void)cfg_map_get(config, "dynamic-db", &dynamic_db_list);
 	element = cfg_list_first(dynamic_db_list);
 	if (element != NULL) {
-		dns_dyndb_arguments_t *args;
-
 		args = dns_dyndb_arguments_create(mctx);
 		if (args == NULL) {
 			result = ISC_R_NOMEMORY;
@@ -3344,11 +3349,8 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig,
 		while (element != NULL) {
 			obj = cfg_listelt_value(element);
 			CHECK(configure_dynamic_db(obj, mctx, args));
-		
 			element = cfg_list_next(element);
 		}
-
-		dns_dyndb_arguments_destroy(mctx, args);
 	}
 
 	/*
@@ -3536,6 +3538,8 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig,
 
 	if (cache != NULL)
 		dns_cache_detach(&cache);
+	if (args != NULL)
+		dns_dyndb_arguments_destroy(mctx, &args);
 
 	return (result);
 }
diff --git a/lib/dns/dynamic_db.c b/lib/dns/dynamic_db.c
index bf83161..a0d26eb 100644
--- a/lib/dns/dynamic_db.c
+++ b/lib/dns/dynamic_db.c
@@ -280,9 +280,15 @@ dns_dyndb_arguments_create(isc_mem_t *mctx)
 }
 
 void
-dns_dyndb_arguments_destroy(isc_mem_t *mctx, dns_dyndb_arguments_t *args)
+dns_dyndb_arguments_destroy(isc_mem_t *mctx, dns_dyndb_arguments_t **argsp)
 {
-	REQUIRE(args != NULL);
+	dns_dyndb_arguments_t *args;
+
+	REQUIRE(argsp != NULL);
+
+	args = *argsp;
+	if (args == NULL)
+		return;
 
 	dns_dyndb_set_view(args, NULL);
 	dns_dyndb_set_zonemgr(args, NULL);
@@ -290,6 +296,8 @@ dns_dyndb_arguments_destroy(isc_mem_t *mctx, dns_dyndb_arguments_t *args)
 	dns_dyndb_set_timermgr(args, NULL);
 
 	isc_mem_put(mctx, args, sizeof(*args));
+
+	*argsp = NULL;
 }
 
 void
diff --git a/lib/dns/include/dns/dynamic_db.h b/lib/dns/include/dns/dynamic_db.h
index 673ad4b..5ecee0e 100644
--- a/lib/dns/include/dns/dynamic_db.h
+++ b/lib/dns/include/dns/dynamic_db.h
@@ -35,7 +35,7 @@ isc_result_t dns_dynamic_db_load(const char *libname, const char *name,
 void dns_dynamic_db_cleanup(isc_boolean_t exiting);
 
 dns_dyndb_arguments_t *dns_dyndb_arguments_create(isc_mem_t *mctx);
-void dns_dyndb_arguments_destroy(isc_mem_t *mctx, dns_dyndb_arguments_t *args);
+void dns_dyndb_arguments_destroy(isc_mem_t *mctx, dns_dyndb_arguments_t **argsp);
 
 void dns_dyndb_set_view(dns_dyndb_arguments_t *args, dns_view_t *view);
 dns_view_t *dns_dyndb_get_view(dns_dyndb_arguments_t *args);
-- 
1.9.3