Commit 2504b0a5 authored by Bob Halley's avatar Bob Halley
Browse files

add cachedb

parent 5f120ce9
......@@ -62,6 +62,7 @@ struct dns_view {
char * name;
dns_dbtable_t * dbtable;
dns_resolver_t * resolver;
dns_db_t * cachedb;
isc_mutex_t lock;
/* Locked by lock. */
unsigned int references;
......@@ -75,7 +76,8 @@ struct dns_view {
isc_result_t
dns_view_create(isc_mem_t *mctx, dns_rdataclass_t rdclass, char *name,
dns_resolver_t *resolver, dns_view_t **viewp);
dns_db_t *cachedb, dns_resolver_t *resolver,
dns_view_t **viewp);
void
dns_view_attach(dns_view_t *source, dns_view_t **targetp);
......
......@@ -28,6 +28,7 @@
#include <dns/types.h>
#include <dns/dbtable.h>
#include <dns/db.h>
#include <dns/resolver.h>
#include <dns/view.h>
......@@ -35,7 +36,8 @@
isc_result_t
dns_view_create(isc_mem_t *mctx, dns_rdataclass_t rdclass, char *name,
dns_resolver_t *resolver, dns_view_t **viewp)
dns_db_t *cachedb, dns_resolver_t *resolver,
dns_view_t **viewp)
{
dns_view_t *view;
isc_result_t result;
......@@ -72,6 +74,9 @@ dns_view_create(isc_mem_t *mctx, dns_rdataclass_t rdclass, char *name,
result = ISC_R_UNEXPECTED;
goto cleanup_mutex;
}
view->cachedb = NULL;
if (cachedb != NULL)
dns_db_attach(cachedb, &view->cachedb);
view->resolver = NULL;
if (resolver != NULL)
dns_resolver_attach(resolver, &view->resolver);
......@@ -119,6 +124,8 @@ destroy(dns_view_t *view) {
if (view->resolver != NULL)
dns_resolver_detach(&view->resolver);
if (view->cachedb != NULL)
dns_db_detach(&view->cachedb);
dns_dbtable_detach(&view->dbtable);
isc_mutex_destroy(&view->lock);
isc_mem_free(view->mctx, view->name);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment