summaryrefslogtreecommitdiffstats
path: root/contrib/bind9/lib/dns/view.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/bind9/lib/dns/view.c')
-rw-r--r--contrib/bind9/lib/dns/view.c48
1 files changed, 35 insertions, 13 deletions
diff --git a/contrib/bind9/lib/dns/view.c b/contrib/bind9/lib/dns/view.c
index 6750058..5b6ad65 100644
--- a/contrib/bind9/lib/dns/view.c
+++ b/contrib/bind9/lib/dns/view.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004-2012 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004-2013 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1999-2003 Internet Software Consortium.
*
* Permission to use, copy, modify, and/or distribute this software for any
@@ -86,6 +86,9 @@ dns_view_create(isc_mem_t *mctx, dns_rdataclass_t rdclass,
view = isc_mem_get(mctx, sizeof(*view));
if (view == NULL)
return (ISC_R_NOMEMORY);
+
+ view->mctx = NULL;
+ isc_mem_attach(mctx, &view->mctx);
view->name = isc_mem_strdup(mctx, name);
if (view->name == NULL) {
result = ISC_R_NOMEMORY;
@@ -95,8 +98,8 @@ dns_view_create(isc_mem_t *mctx, dns_rdataclass_t rdclass,
if (result != ISC_R_SUCCESS)
goto cleanup_name;
-#ifdef BIND9
view->zonetable = NULL;
+#ifdef BIND9
result = dns_zt_create(mctx, rdclass, &view->zonetable);
if (result != ISC_R_SUCCESS) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
@@ -125,7 +128,6 @@ dns_view_create(isc_mem_t *mctx, dns_rdataclass_t rdclass,
view->resolver = NULL;
view->adb = NULL;
view->requestmgr = NULL;
- view->mctx = mctx;
view->rdclass = rdclass;
view->frozen = ISC_FALSE;
view->task = NULL;
@@ -225,6 +227,7 @@ dns_view_create(isc_mem_t *mctx, dns_rdataclass_t rdclass,
ISC_EVENT_INIT(&view->reqevent, sizeof(view->reqevent), 0, NULL,
DNS_EVENT_VIEWREQSHUTDOWN, req_shutdown,
view, NULL, NULL, NULL);
+ view->viewlist = NULL;
view->magic = DNS_VIEW_MAGIC;
*viewp = view;
@@ -260,7 +263,7 @@ dns_view_create(isc_mem_t *mctx, dns_rdataclass_t rdclass,
isc_mem_free(mctx, view->name);
cleanup_view:
- isc_mem_put(mctx, view, sizeof(*view));
+ isc_mem_putanddetach(&view->mctx, view, sizeof(*view));
return (result);
}
@@ -439,7 +442,7 @@ destroy(dns_view_t *view) {
DESTROYLOCK(&view->lock);
isc_refcount_destroy(&view->references);
isc_mem_free(view->mctx, view->name);
- isc_mem_put(view->mctx, view, sizeof(*view));
+ isc_mem_putanddetach(&view->mctx, view, sizeof(*view));
}
/*
@@ -482,6 +485,10 @@ view_flushanddetach(dns_view_t **viewp, isc_boolean_t flush) {
view->flush = ISC_TRUE;
isc_refcount_decrement(&view->references, &refs);
if (refs == 0) {
+#ifdef BIND9
+ dns_zone_t *mkzone = NULL;
+#endif
+
LOCK(&view->lock);
if (!RESSHUTDOWN(view))
dns_resolver_shutdown(view->resolver);
@@ -497,13 +504,20 @@ view_flushanddetach(dns_view_t **viewp, isc_boolean_t flush) {
else
dns_zt_detach(&view->zonetable);
if (view->managed_keys != NULL) {
+ mkzone = view->managed_keys;
+ view->managed_keys = NULL;
if (view->flush)
- dns_zone_flush(view->managed_keys);
- dns_zone_detach(&view->managed_keys);
+ dns_zone_flush(mkzone);
}
#endif
done = all_done(view);
UNLOCK(&view->lock);
+
+#ifdef BIND9
+ /* Need to detach zones outside view lock */
+ if (mkzone != NULL)
+ dns_zone_detach(&mkzone);
+#endif
}
*viewp = NULL;
@@ -855,11 +869,14 @@ dns_view_findzone(dns_view_t *view, dns_name_t *name, dns_zone_t **zonep) {
REQUIRE(DNS_VIEW_VALID(view));
- result = dns_zt_find(view->zonetable, name, 0, NULL, zonep);
- if (result == DNS_R_PARTIALMATCH) {
- dns_zone_detach(zonep);
+ if (view->zonetable != NULL) {
+ result = dns_zt_find(view->zonetable, name, 0, NULL, zonep);
+ if (result == DNS_R_PARTIALMATCH) {
+ dns_zone_detach(zonep);
+ result = ISC_R_NOTFOUND;
+ }
+ } else
result = ISC_R_NOTFOUND;
- }
return (result);
}
@@ -892,6 +909,7 @@ dns_view_find2(dns_view_t *view, dns_name_t *name, dns_rdatatype_t type,
#ifndef BIND9
UNUSED(use_hints);
UNUSED(use_static_stub);
+ UNUSED(zone);
#endif
/*
@@ -916,11 +934,11 @@ dns_view_find2(dns_view_t *view, dns_name_t *name, dns_rdatatype_t type,
/*
* Find a database to answer the query.
*/
- zone = NULL;
db = NULL;
node = NULL;
is_staticstub_zone = ISC_FALSE;
#ifdef BIND9
+ zone = NULL;
result = dns_zt_find(view->zonetable, name, 0, NULL, &zone);
if (zone != NULL && dns_zone_gettype(zone) == dns_zone_staticstub &&
!use_static_stub) {
@@ -1168,11 +1186,14 @@ dns_view_findzonecut2(dns_view_t *view, dns_name_t *name, dns_name_t *fname,
dns_rdataset_t zrdataset, zsigrdataset;
dns_fixedname_t zfixedname;
+#ifndef BIND9
+ UNUSED(zone);
+#endif
+
REQUIRE(DNS_VIEW_VALID(view));
REQUIRE(view->frozen);
db = NULL;
- zone = NULL;
use_zone = ISC_FALSE;
try_hints = ISC_FALSE;
zfname = NULL;
@@ -1188,6 +1209,7 @@ dns_view_findzonecut2(dns_view_t *view, dns_name_t *name, dns_name_t *fname,
* Find the right database.
*/
#ifdef BIND9
+ zone = NULL;
result = dns_zt_find(view->zonetable, name, 0, NULL, &zone);
if (result == ISC_R_SUCCESS || result == DNS_R_PARTIALMATCH)
result = dns_zone_getdb(zone, &db);
OpenPOWER on IntegriCloud