d4e835
From 1f6c240231fcb9fe8bc4a28f3359201c2a1d8465 Mon Sep 17 00:00:00 2001
d4e835
From: Tomas Hozza <thozza@redhat.com>
d4e835
Date: Wed, 17 Sep 2014 20:00:39 +0200
d4e835
Subject: [PATCH] Fix for BZ #1142150
d4e835
d4e835
Signed-off-by: Tomas Hozza <thozza@redhat.com>
d4e835
---
d4e835
 bin/named/server.c               | 14 +++++++++-----
d4e835
 lib/dns/dynamic_db.c             | 12 ++++++++++--
d4e835
 lib/dns/include/dns/dynamic_db.h |  2 +-
d4e835
 3 files changed, 20 insertions(+), 8 deletions(-)
d4e835
d4e835
diff --git a/bin/named/server.c b/bin/named/server.c
d4e835
index ee04dda..6f8b0f0 100644
d4e835
--- a/bin/named/server.c
d4e835
+++ b/bin/named/server.c
d4e835
@@ -1302,6 +1302,12 @@ configure_dynamic_db(const cfg_obj_t *dynamic_db, isc_mem_t *mctx,
d4e835
 	CHECK(dns_dynamic_db_load(libname, name, mctx, argv, dyndb_args));
d4e835
 
d4e835
 cleanup:
d4e835
+
d4e835
+	if (result != ISC_R_SUCCESS)
d4e835
+		isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
d4e835
+		              NS_LOGMODULE_SERVER, ISC_LOG_ERROR,
d4e835
+		              "dynamic database '%s' configuration failed: %s",
d4e835
+		              name, isc_result_totext(result));
d4e835
 	if (argv != NULL)
d4e835
 		isc_mem_free(mctx, argv);
d4e835
 
d4e835
@@ -2165,6 +2171,7 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig,
d4e835
 	unsigned int query_timeout, ndisp;
d4e835
 	struct cfg_context *nzctx;
d4e835
 	dns_rpz_zone_t *rpz;
d4e835
+	dns_dyndb_arguments_t *args = NULL;
d4e835
 
d4e835
 	REQUIRE(DNS_VIEW_VALID(view));
d4e835
 
d4e835
@@ -3330,8 +3337,6 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig,
d4e835
 		(void)cfg_map_get(config, "dynamic-db", &dynamic_db_list);
d4e835
 	element = cfg_list_first(dynamic_db_list);
d4e835
 	if (element != NULL) {
d4e835
-		dns_dyndb_arguments_t *args;
d4e835
-
d4e835
 		args = dns_dyndb_arguments_create(mctx);
d4e835
 		if (args == NULL) {
d4e835
 			result = ISC_R_NOMEMORY;
d4e835
@@ -3344,11 +3349,8 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig,
d4e835
 		while (element != NULL) {
d4e835
 			obj = cfg_listelt_value(element);
d4e835
 			CHECK(configure_dynamic_db(obj, mctx, args));
d4e835
-		
d4e835
 			element = cfg_list_next(element);
d4e835
 		}
d4e835
-
d4e835
-		dns_dyndb_arguments_destroy(mctx, args);
d4e835
 	}
d4e835
 
d4e835
 	/*
d4e835
@@ -3536,6 +3538,8 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig,
d4e835
 
d4e835
 	if (cache != NULL)
d4e835
 		dns_cache_detach(&cache);
d4e835
+	if (args != NULL)
d4e835
+		dns_dyndb_arguments_destroy(mctx, &args);
d4e835
 
d4e835
 	return (result);
d4e835
 }
d4e835
diff --git a/lib/dns/dynamic_db.c b/lib/dns/dynamic_db.c
d4e835
index bf83161..a0d26eb 100644
d4e835
--- a/lib/dns/dynamic_db.c
d4e835
+++ b/lib/dns/dynamic_db.c
d4e835
@@ -280,9 +280,15 @@ dns_dyndb_arguments_create(isc_mem_t *mctx)
d4e835
 }
d4e835
 
d4e835
 void
d4e835
-dns_dyndb_arguments_destroy(isc_mem_t *mctx, dns_dyndb_arguments_t *args)
d4e835
+dns_dyndb_arguments_destroy(isc_mem_t *mctx, dns_dyndb_arguments_t **argsp)
d4e835
 {
d4e835
-	REQUIRE(args != NULL);
d4e835
+	dns_dyndb_arguments_t *args;
d4e835
+
d4e835
+	REQUIRE(argsp != NULL);
d4e835
+
d4e835
+	args = *argsp;
d4e835
+	if (args == NULL)
d4e835
+		return;
d4e835
 
d4e835
 	dns_dyndb_set_view(args, NULL);
d4e835
 	dns_dyndb_set_zonemgr(args, NULL);
d4e835
@@ -290,6 +296,8 @@ dns_dyndb_arguments_destroy(isc_mem_t *mctx, dns_dyndb_arguments_t *args)
d4e835
 	dns_dyndb_set_timermgr(args, NULL);
d4e835
 
d4e835
 	isc_mem_put(mctx, args, sizeof(*args));
d4e835
+
d4e835
+	*argsp = NULL;
d4e835
 }
d4e835
 
d4e835
 void
d4e835
diff --git a/lib/dns/include/dns/dynamic_db.h b/lib/dns/include/dns/dynamic_db.h
d4e835
index 673ad4b..5ecee0e 100644
d4e835
--- a/lib/dns/include/dns/dynamic_db.h
d4e835
+++ b/lib/dns/include/dns/dynamic_db.h
d4e835
@@ -35,7 +35,7 @@ isc_result_t dns_dynamic_db_load(const char *libname, const char *name,
d4e835
 void dns_dynamic_db_cleanup(isc_boolean_t exiting);
d4e835
 
d4e835
 dns_dyndb_arguments_t *dns_dyndb_arguments_create(isc_mem_t *mctx);
d4e835
-void dns_dyndb_arguments_destroy(isc_mem_t *mctx, dns_dyndb_arguments_t *args);
d4e835
+void dns_dyndb_arguments_destroy(isc_mem_t *mctx, dns_dyndb_arguments_t **argsp);
d4e835
 
d4e835
 void dns_dyndb_set_view(dns_dyndb_arguments_t *args, dns_view_t *view);
d4e835
 dns_view_t *dns_dyndb_get_view(dns_dyndb_arguments_t *args);
d4e835
-- 
d4e835
1.9.3
d4e835