diff --git a/bin/named/server.c b/bin/named/server.c index 55debbed59..38ec90d75e 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -35,6 +35,7 @@ #include #include +#include #include #include #include @@ -77,7 +78,8 @@ create_default_view(isc_mem_t *mctx, dns_rdataclass_t rdclass, dns_view_t **viewp) { dns_view_t *view; - dns_db_t *db; + dns_cache_t *cache; + isc_result_t result; REQUIRE(viewp != NULL && *viewp == NULL); @@ -93,13 +95,13 @@ create_default_view(isc_mem_t *mctx, dns_rdataclass_t rdclass, /* * Cache. */ - db = NULL; - result = dns_db_create(mctx, "rbt", dns_rootname, ISC_TRUE, - rdclass, 0, NULL, &db); + cache = NULL; + result = dns_cache_create(mctx, ns_g_taskmgr, ns_g_timermgr, rdclass, + "rbt", 0, NULL, &cache); if (result != ISC_R_SUCCESS) goto cleanup; - dns_view_setcachedb(view, db); - dns_db_detach(&db); + dns_view_setcache(view, cache); + dns_cache_detach(&cache); /* * XXXRTH Temporary support for loading cache contents. diff --git a/bin/tests/adb_test.c b/bin/tests/adb_test.c index 3f5b528367..6d76483804 100644 --- a/bin/tests/adb_test.c +++ b/bin/tests/adb_test.c @@ -36,6 +36,7 @@ #include #include +#include #include #include #include @@ -253,7 +254,7 @@ create_managers(void) void create_view(void) { - dns_db_t *db; + dns_cache_t *cache; isc_result_t result; /* @@ -266,12 +267,12 @@ create_view(void) /* * Cache. */ - db = NULL; - result = dns_db_create(mctx, "rbt", dns_rootname, ISC_TRUE, - dns_rdataclass_in, 0, NULL, &db); - check_result(result, "dns_view_create"); - dns_view_setcachedb(view, db); - dns_db_detach(&db); + cache = NULL; + result = dns_cache_create(mctx, taskmgr, timermgr, dns_rdataclass_in, + "rbt", 0, NULL, &cache); + check_result(result, "dns_cache_create"); + dns_view_setcache(view, cache); + dns_cache_detach(&cache); /* * Resolver. diff --git a/lib/dns/include/dns/view.h b/lib/dns/include/dns/view.h index 6c35731656..1e41e2a614 100644 --- a/lib/dns/include/dns/view.h +++ b/lib/dns/include/dns/view.h @@ -80,6 +80,7 @@ struct dns_view { dns_zt_t * zonetable; dns_resolver_t * resolver; dns_adb_t * adb; + dns_cache_t * cache; dns_db_t * cachedb; dns_db_t * hints; dns_rbt_t * secroots; @@ -191,27 +192,22 @@ dns_view_createresolver(dns_view_t *view, */ void -dns_view_setcachedb(dns_view_t *view, dns_db_t *cachedb); +dns_view_setcache(dns_view_t *view, dns_cache_t *cache); /* * Set the view's cache database. * - * Note: - * - * WARNING! THIS ROUTINE WILL BE REPLACED WITH dns_view_setcache() - * WHEN WE HAVE INTEGRATED CACHE OBJECT SUPPORT INTO THE LIBRARY. - * * Requires: * * 'view' is a valid, unfrozen view. * - * 'cachedb' is a valid cache database. + * 'cache' is a valid cache. * * Ensures: * - * The cache database of 'view' is 'cachedb'. + * The cache of 'view' is 'cached. * - * If this is not the first call to dns_view_setcachedb() for this - * view, then previously set db is detached. + * If this is not the first call to dns_view_setcache() for this + * view, then previously set cache is detached. */ void diff --git a/lib/dns/view.c b/lib/dns/view.c index 03dae967c5..5f636e157c 100644 --- a/lib/dns/view.c +++ b/lib/dns/view.c @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -93,6 +94,7 @@ dns_view_create(isc_mem_t *mctx, dns_rdataclass_t rdclass, goto cleanup_zt; } + view->cache = NULL; view->cachedb = NULL; view->hints = NULL; view->resolver = NULL; @@ -169,6 +171,8 @@ destroy(dns_view_t *view) { dns_db_detach(&view->hints); if (view->cachedb != NULL) dns_db_detach(&view->cachedb); + if (view->cache != NULL) + dns_cache_detach(&view->cache); dns_zt_detach(&view->zonetable); dns_rbt_destroy(&view->secroots); isc_mutex_destroy(&view->lock); @@ -310,24 +314,22 @@ dns_view_createresolver(dns_view_t *view, } void -dns_view_setcachedb(dns_view_t *view, dns_db_t *cachedb) { +dns_view_setcache(dns_view_t *view, dns_cache_t *cache) { /* - * Set the view's cache database. - */ - - /* - * WARNING! THIS ROUTINE WILL BE REPLACED WITH dns_view_setcache() - * WHEN WE HAVE INTEGRATED CACHE OBJECT SUPPORT INTO THE LIBRARY. + * Set the view's cache. */ REQUIRE(DNS_VIEW_VALID(view)); REQUIRE(!view->frozen); - REQUIRE(dns_db_iscache(cachedb)); - if (view->cachedb != NULL) + if (view->cache != NULL) { dns_db_detach(&view->cachedb); - dns_db_attach(cachedb, &view->cachedb); + dns_cache_detach(&view->cache); + } + dns_cache_attach(cache, &view->cache); + dns_cache_attachdb(cache, &view->cachedb); + INSIST(DNS_DB_VALID(view->cachedb)); } void