2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-29 13:38:26 +00:00

808. [func] Add 'rndc flush' to flush the server's cache.

This commit is contained in:
Brian Wellington 2001-04-11 20:37:50 +00:00
parent 9ffcab1e9a
commit c20ffa38de
13 changed files with 244 additions and 66 deletions

View File

@ -1,4 +1,6 @@
808. [func] Add 'rndc flush' to flush the server's cache.
807. [bug] When setting up TCP connections for incoming zone 807. [bug] When setting up TCP connections for incoming zone
transfers, the transfer-source port was not transfers, the transfer-source port was not
ignored like it should be. ignored like it should be.

View File

@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: control.c,v 1.2 2001/04/10 21:50:40 bwelling Exp $ */ /* $Id: control.c,v 1.3 2001/04/11 20:37:33 bwelling Exp $ */
#include <config.h> #include <config.h>
@ -109,6 +109,8 @@ ns_control_docommand(isccc_sexpr_t *message) {
ns_g_debuglevel = 0; ns_g_debuglevel = 0;
isc_log_setdebuglevel(ns_g_lctx, ns_g_debuglevel); isc_log_setdebuglevel(ns_g_lctx, ns_g_debuglevel);
result = ISC_R_SUCCESS; result = ISC_R_SUCCESS;
} else if (command_compare(command, NS_COMMAND_FLUSH)) {
result = ns_server_flushcache(ns_g_server);
} else { } else {
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
NS_LOGMODULE_CONTROL, ISC_LOG_WARNING, NS_LOGMODULE_CONTROL, ISC_LOG_WARNING,

View File

@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: control.h,v 1.2 2001/04/10 21:50:45 bwelling Exp $ */ /* $Id: control.h,v 1.3 2001/04/11 20:37:36 bwelling Exp $ */
#ifndef NAMED_CONTROL_H #ifndef NAMED_CONTROL_H
#define NAMED_CONTROL_H 1 #define NAMED_CONTROL_H 1
@ -37,6 +37,7 @@
#define NS_COMMAND_DUMPDB "dumpdb" #define NS_COMMAND_DUMPDB "dumpdb"
#define NS_COMMAND_TRACE "trace" #define NS_COMMAND_TRACE "trace"
#define NS_COMMAND_NOTRACE "notrace" #define NS_COMMAND_NOTRACE "notrace"
#define NS_COMMAND_FLUSH "flush"
isc_result_t isc_result_t
ns_control_init(void); ns_control_init(void);

View File

@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: server.h,v 1.52 2001/02/14 03:50:08 gson Exp $ */ /* $Id: server.h,v 1.53 2001/04/11 20:37:37 bwelling Exp $ */
#ifndef NAMED_SERVER_H #ifndef NAMED_SERVER_H
#define NAMED_SERVER_H 1 #define NAMED_SERVER_H 1
@ -148,4 +148,10 @@ ns_server_dumpdb(ns_server_t *server);
isc_result_t isc_result_t
ns_server_setdebuglevel(ns_server_t *server, char *args); ns_server_setdebuglevel(ns_server_t *server, char *args);
/*
* Flush the server's cache(s)
*/
isc_result_t
ns_server_flushcache(ns_server_t *server);
#endif /* NAMED_SERVER_H */ #endif /* NAMED_SERVER_H */

View File

@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: server.c,v 1.315 2001/03/29 04:25:59 gson Exp $ */ /* $Id: server.c,v 1.316 2001/04/11 20:37:34 bwelling Exp $ */
#include <config.h> #include <config.h>
@ -2685,3 +2685,24 @@ ns_server_setdebuglevel(ns_server_t *server, char *args) {
isc_log_setdebuglevel(ns_g_lctx, ns_g_debuglevel); isc_log_setdebuglevel(ns_g_lctx, ns_g_debuglevel);
return (ISC_R_SUCCESS); return (ISC_R_SUCCESS);
} }
isc_result_t
ns_server_flushcache(ns_server_t *server) {
dns_view_t *view;
isc_result_t result;
result = isc_task_beginexclusive(server->task);
RUNTIME_CHECK(result == ISC_R_SUCCESS);
for (view = ISC_LIST_HEAD(server->viewlist);
view != NULL;
view = ISC_LIST_NEXT(view, link))
{
result = dns_view_flushcache(view);
if (result != ISC_R_SUCCESS)
goto out;
}
result = ISC_R_SUCCESS;
out:
isc_task_endexclusive(server->task);
return (result);
}

View File

@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: rndc.c,v 1.52 2001/04/10 22:00:41 bwelling Exp $ */ /* $Id: rndc.c,v 1.53 2001/04/11 20:37:39 bwelling Exp $ */
/* /*
* Principal Author: DCL * Principal Author: DCL
@ -110,6 +110,7 @@ command is one of the following:\n\
trace Increment debugging level by one.\n\ trace Increment debugging level by one.\n\
trace level Change the debugging level.\n\ trace level Change the debugging level.\n\
notrace Set debugging level to 0.\n\ notrace Set debugging level to 0.\n\
flush Flushes the server's cache.\n\
*status Display ps(1) status of named.\n\ *status Display ps(1) status of named.\n\
*restart Restart the server.\n\ *restart Restart the server.\n\
\n\ \n\

View File

@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: adb.c,v 1.173 2001/04/10 00:18:27 gson Exp $ */ /* $Id: adb.c,v 1.174 2001/04/11 20:37:40 bwelling Exp $ */
/* /*
* Implementation notes * Implementation notes
@ -4008,3 +4008,26 @@ dns_adb_freeaddrinfo(dns_adb_t *adb, dns_adbaddrinfo_t **addrp) {
UNLOCK(&adb->lock); UNLOCK(&adb->lock);
} }
} }
void
dns_adb_flush(dns_adb_t *adb) {
unsigned int i;
INSIST(DNS_ADB_VALID(adb));
LOCK(&adb->lock);
for (i = 0 ; i < NBUCKETS ; i++) {
/*
* Call our cleanup routines.
*/
cleanup_names(adb, i, INT_MAX);
cleanup_entries(adb, i, INT_MAX);
}
#ifdef DUMP_ADB_AFTER_CLEANING
dump_adb(adb, stdout, ISC_TRUE);
#endif
UNLOCK(&adb->lock);
}

View File

@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: cache.c,v 1.35 2001/03/08 01:22:48 tale Exp $ */ /* $Id: cache.c,v 1.36 2001/04/11 20:37:42 bwelling Exp $ */
#include <config.h> #include <config.h>
@ -97,6 +97,9 @@ struct dns_cache {
dns_rdataclass_t rdclass; dns_rdataclass_t rdclass;
dns_db_t *db; dns_db_t *db;
cache_cleaner_t cleaner; cache_cleaner_t cleaner;
char *db_type;
int db_argc;
char **db_argv;
/* Locked by 'filelock'. */ /* Locked by 'filelock'. */
char * filename; char * filename;
@ -124,6 +127,13 @@ cleaner_shutdown_action(isc_task_t *task, isc_event_t *event);
static void static void
overmem_cleaning_action(isc_task_t *task, isc_event_t *event); overmem_cleaning_action(isc_task_t *task, isc_event_t *event);
static inline isc_result_t
cache_create_db(dns_cache_t *cache, dns_db_t **db) {
return (dns_db_create(cache->mctx, cache->db_type, dns_rootname,
dns_dbtype_cache, cache->rdclass,
cache->db_argc, cache->db_argv, db));
}
isc_result_t isc_result_t
dns_cache_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr, dns_cache_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr,
isc_timermgr_t *timermgr, dns_rdataclass_t rdclass, isc_timermgr_t *timermgr, dns_rdataclass_t rdclass,
@ -132,6 +142,7 @@ dns_cache_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr,
{ {
isc_result_t result; isc_result_t result;
dns_cache_t *cache; dns_cache_t *cache;
int i;
REQUIRE(cachep != NULL); REQUIRE(cachep != NULL);
REQUIRE(*cachep == NULL); REQUIRE(*cachep == NULL);
@ -166,12 +177,37 @@ dns_cache_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr,
cache->live_tasks = 0; cache->live_tasks = 0;
cache->rdclass = rdclass; cache->rdclass = rdclass;
cache->db = NULL; cache->db_type = isc_mem_strdup(mctx, db_type);
result = dns_db_create(cache->mctx, db_type, dns_rootname, if (cache->db_type == NULL) {
dns_dbtype_cache, rdclass, db_argc, db_argv, result = ISC_R_NOMEMORY;
&cache->db);
if (result != ISC_R_SUCCESS)
goto cleanup_filelock; goto cleanup_filelock;
}
cache->db_argc = db_argc;
if (cache->db_argc == 0)
cache->db_argv = NULL;
else {
cache->db_argv = isc_mem_get(mctx,
cache->db_argc * sizeof(char *));
if (cache->db_argv == NULL) {
result = ISC_R_NOMEMORY;
goto cleanup_dbtype;
}
for (i = 0; i < cache->db_argc; i++)
cache->db_argv[i] = NULL;
for (i = 0; i < cache->db_argc; i++) {
cache->db_argv[i] = isc_mem_strdup(mctx, db_argv[i]);
if (cache->db_argv[i] == NULL) {
result = ISC_R_NOMEMORY;
goto cleanup_dbargv;
}
}
}
cache->db = NULL;
result = cache_create_db(cache, &cache->db);
if (result != ISC_R_SUCCESS)
goto cleanup_dbargv;
cache->filename = NULL; cache->filename = NULL;
@ -187,6 +223,13 @@ dns_cache_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr,
cleanup_db: cleanup_db:
dns_db_detach(&cache->db); dns_db_detach(&cache->db);
cleanup_dbargv:
for (i = 0; i < cache->db_argc; i++)
if (cache->db_argv[i] != NULL)
isc_mem_free(mctx, cache->db_argv[i]);
isc_mem_put(mctx, cache->db_argv, cache->db_argc * sizeof(char *));
cleanup_dbtype:
isc_mem_free(mctx, cache->db_type);
cleanup_filelock: cleanup_filelock:
DESTROYLOCK(&cache->filelock); DESTROYLOCK(&cache->filelock);
cleanup_lock: cleanup_lock:
@ -200,6 +243,7 @@ dns_cache_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr,
static void static void
cache_free(dns_cache_t *cache) { cache_free(dns_cache_t *cache) {
isc_mem_t *mctx; isc_mem_t *mctx;
int i;
REQUIRE(VALID_CACHE(cache)); REQUIRE(VALID_CACHE(cache));
REQUIRE(cache->references == 0); REQUIRE(cache->references == 0);
@ -223,9 +267,20 @@ cache_free(dns_cache_t *cache) {
cache->filename = NULL; cache->filename = NULL;
} }
if (cache->db) if (cache->db != NULL)
dns_db_detach(&cache->db); dns_db_detach(&cache->db);
if (cache->db_argv != NULL) {
for (i = 0; i < cache->db_argc; i++)
if (cache->db_argv[i] != NULL)
isc_mem_free(cache->mctx, cache->db_argv[i]);
isc_mem_put(cache->mctx, cache->db_argv,
cache->db_argc * sizeof(char *));
}
if (cache->db_type != NULL)
isc_mem_free(cache->mctx, cache->db_type);
DESTROYLOCK(&cache->lock); DESTROYLOCK(&cache->lock);
DESTROYLOCK(&cache->filelock); DESTROYLOCK(&cache->filelock);
cache->magic = 0; cache->magic = 0;
@ -802,3 +857,17 @@ cleaner_shutdown_action(isc_task_t *task, isc_event_t *event) {
if (should_free) if (should_free)
cache_free(cache); cache_free(cache);
} }
isc_result_t
dns_cache_flush(dns_cache_t *cache) {
dns_db_t *db = NULL;
isc_result_t result;
result = cache_create_db(cache, &db);
if (result != ISC_R_SUCCESS)
return (result);
dns_db_detach(&cache->db);
cache->db = db;
return (ISC_R_SUCCESS);
}

View File

@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: adb.h,v 1.64 2001/02/28 20:47:36 gson Exp $ */ /* $Id: adb.h,v 1.65 2001/04/11 20:37:48 bwelling Exp $ */
#ifndef DNS_ADB_H #ifndef DNS_ADB_H
#define DNS_ADB_H 1 #define DNS_ADB_H 1
@ -559,6 +559,15 @@ dns_adb_freeaddrinfo(dns_adb_t *adb, dns_adbaddrinfo_t **addrp);
* *addrp is a valid dns_adbaddrinfo_t *. * *addrp is a valid dns_adbaddrinfo_t *.
*/ */
void
dns_adb_flush(dns_adb_t *adb);
/*
* Flushes all cached data from the adb.
*
* Requires:
* adb is valid.
*/
ISC_LANG_ENDDECLS ISC_LANG_ENDDECLS
#endif /* DNS_ADB_H */ #endif /* DNS_ADB_H */

View File

@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: cache.h,v 1.16 2001/01/09 21:52:19 bwelling Exp $ */ /* $Id: cache.h,v 1.17 2001/04/11 20:37:49 bwelling Exp $ */
#ifndef DNS_CACHE_H #ifndef DNS_CACHE_H
#define DNS_CACHE_H 1 #define DNS_CACHE_H 1
@ -225,6 +225,16 @@ dns_cache_setcachesize(dns_cache_t *cache, isc_uint32_t size);
* Set the maximum cache size. 0 means unlimited. * Set the maximum cache size. 0 means unlimited.
*/ */
isc_result_t
dns_cache_flush(dns_cache_t *cache);
/*
* Flushes all data from the cache.
*
* Returns:
* ISC_R_SUCCESS
* ISC_R_NOMEMORY
*/
ISC_LANG_ENDDECLS ISC_LANG_ENDDECLS
#endif /* DNS_CACHE_H */ #endif /* DNS_CACHE_H */

View File

@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: view.h,v 1.69 2001/03/26 21:33:04 bwelling Exp $ */ /* $Id: view.h,v 1.70 2001/04/11 20:37:50 bwelling Exp $ */
#ifndef DNS_VIEW_H #ifndef DNS_VIEW_H
#define DNS_VIEW_H 1 #define DNS_VIEW_H 1
@ -666,6 +666,21 @@ dns_view_dumpdbtostream(dns_view_t *view, FILE *fp);
* others An error occurred (see dns_master_dump) * others An error occurred (see dns_master_dump)
*/ */
isc_result_t
dns_view_flushcache(dns_view_t *view);
/*
* Flush the view's cache (and ADB).
*
* Requires:
* 'view' is valid.
*
* No other tasks are executing.
*
* Returns:
* ISC_R_SUCCESS
* ISC_R_NOMEMORY
*/
ISC_LANG_ENDDECLS ISC_LANG_ENDDECLS
#endif /* DNS_VIEW_H */ #endif /* DNS_VIEW_H */

View File

@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: resolver.c,v 1.214 2001/03/26 21:32:58 bwelling Exp $ */ /* $Id: resolver.c,v 1.215 2001/04/11 20:37:44 bwelling Exp $ */
#include <config.h> #include <config.h>
@ -173,6 +173,8 @@ struct fetchctx {
dns_fwdpolicy_t fwdpolicy; dns_fwdpolicy_t fwdpolicy;
isc_sockaddrlist_t bad; isc_sockaddrlist_t bad;
ISC_LIST(dns_validator_t) validators; ISC_LIST(dns_validator_t) validators;
dns_db_t * cache;
dns_adb_t * adb;
/* /*
* The number of events we're waiting for. * The number of events we're waiting for.
@ -406,8 +408,7 @@ fctx_cancelquery(resquery_t **queryp, dns_dispatchevent_t **deventp,
*/ */
factor = DNS_ADB_RTTADJREPLACE; factor = DNS_ADB_RTTADJREPLACE;
} }
dns_adb_adjustsrtt(fctx->res->view->adb, query->addrinfo, rtt, dns_adb_adjustsrtt(fctx->adb, query->addrinfo, rtt, factor);
factor);
} }
if (query->dispentry != NULL) if (query->dispentry != NULL)
@ -491,7 +492,7 @@ fctx_cleanupforwaddrs(fetchctx_t *fctx) {
addr = next_addr) { addr = next_addr) {
next_addr = ISC_LIST_NEXT(addr, publink); next_addr = ISC_LIST_NEXT(addr, publink);
ISC_LIST_UNLINK(fctx->forwaddrs, addr, publink); ISC_LIST_UNLINK(fctx->forwaddrs, addr, publink);
dns_adb_freeaddrinfo(fctx->res->view->adb, &addr); dns_adb_freeaddrinfo(fctx->adb, &addr);
} }
} }
@ -976,7 +977,7 @@ resquery_send(resquery_t *query) {
!useedns) !useedns)
{ {
query->options |= DNS_FETCHOPT_NOEDNS0; query->options |= DNS_FETCHOPT_NOEDNS0;
dns_adb_changeflags(fctx->res->view->adb, dns_adb_changeflags(fctx->adb,
query->addrinfo, query->addrinfo,
DNS_FETCHOPT_NOEDNS0, DNS_FETCHOPT_NOEDNS0,
DNS_FETCHOPT_NOEDNS0); DNS_FETCHOPT_NOEDNS0);
@ -1477,7 +1478,7 @@ fctx_getaddresses(fetchctx_t *fctx) {
while (sa != NULL) { while (sa != NULL) {
ai = NULL; ai = NULL;
result = dns_adb_findaddrinfo(fctx->res->view->adb, result = dns_adb_findaddrinfo(fctx->adb,
sa, &ai, 0); /* XXXMLG */ sa, &ai, 0); /* XXXMLG */
if (result == ISC_R_SUCCESS) { if (result == ISC_R_SUCCESS) {
ai->flags |= FCTX_ADDRINFO_FORWARDER; ai->flags |= FCTX_ADDRINFO_FORWARDER;
@ -1556,7 +1557,7 @@ fctx_getaddresses(fetchctx_t *fctx) {
* See what we know about this address. * See what we know about this address.
*/ */
find = NULL; find = NULL;
result = dns_adb_createfind(res->view->adb, result = dns_adb_createfind(fctx->adb,
res->buckets[fctx->bucketnum].task, res->buckets[fctx->bucketnum].task,
fctx_finddone, fctx, &ns.name, fctx_finddone, fctx, &ns.name,
&fctx->domain, options, now, NULL, &fctx->domain, options, now, NULL,
@ -1848,6 +1849,8 @@ fctx_destroy(fetchctx_t *fctx) {
if (dns_rdataset_isassociated(&fctx->nameservers)) if (dns_rdataset_isassociated(&fctx->nameservers))
dns_rdataset_disassociate(&fctx->nameservers); dns_rdataset_disassociate(&fctx->nameservers);
dns_name_free(&fctx->name, res->mctx); dns_name_free(&fctx->name, res->mctx);
dns_db_detach(&fctx->cache);
dns_adb_detach(&fctx->adb);
isc_mem_put(res->mctx, fctx, sizeof *fctx); isc_mem_put(res->mctx, fctx, sizeof *fctx);
if (res->buckets[bucketnum].exiting && if (res->buckets[bucketnum].exiting &&
@ -2258,6 +2261,14 @@ fctx_create(dns_resolver_t *res, dns_name_t *name, dns_rdatatype_t type,
goto cleanup_rmessage; goto cleanup_rmessage;
} }
/*
* Attach to the view's cache and adb.
*/
fctx->cache = NULL;
dns_db_attach(res->view->cachedb, &fctx->cache);
fctx->adb = NULL;
dns_adb_attach(res->view->adb, &fctx->adb);
ISC_LIST_INIT(fctx->events); ISC_LIST_INIT(fctx->events);
ISC_LINK_INIT(fctx, link); ISC_LINK_INIT(fctx, link);
fctx->magic = FCTX_MAGIC; fctx->magic = FCTX_MAGIC;
@ -2558,20 +2569,17 @@ validated(isc_task_t *task, isc_event_t *event) {
if (vevent->result != ISC_R_SUCCESS) { if (vevent->result != ISC_R_SUCCESS) {
FCTXTRACE("validation failed"); FCTXTRACE("validation failed");
if (vevent->rdataset != NULL) { if (vevent->rdataset != NULL) {
result = dns_db_findnode(fctx->res->view->cachedb, result = dns_db_findnode(fctx->cache, vevent->name,
vevent->name, ISC_TRUE, ISC_TRUE, &node);
&node);
if (result != ISC_R_SUCCESS) if (result != ISC_R_SUCCESS)
goto noanswer_response; goto noanswer_response;
(void)dns_db_deleterdataset(fctx->res->view->cachedb, (void)dns_db_deleterdataset(fctx->cache, node, NULL,
node, NULL,
vevent->type, 0); vevent->type, 0);
if (vevent->sigrdataset != NULL) if (vevent->sigrdataset != NULL)
(void)dns_db_deleterdataset( (void)dns_db_deleterdataset(fctx->cache,
fctx->res->view->cachedb, node, NULL,
node, NULL, dns_rdatatype_sig,
dns_rdatatype_sig, vevent->type);
vevent->type);
} }
result = vevent->result; result = vevent->result;
goto noanswer_response; goto noanswer_response;
@ -2588,8 +2596,8 @@ validated(isc_task_t *task, isc_event_t *event) {
else else
covers = fctx->type; covers = fctx->type;
result = dns_db_findnode(fctx->res->view->cachedb, result = dns_db_findnode(fctx->cache, vevent->name, ISC_TRUE,
vevent->name, ISC_TRUE, &node); &node);
if (result != ISC_R_SUCCESS) if (result != ISC_R_SUCCESS)
goto noanswer_response; goto noanswer_response;
@ -2603,8 +2611,7 @@ validated(isc_task_t *task, isc_event_t *event) {
covers == dns_rdatatype_any) covers == dns_rdatatype_any)
ttl = 0; ttl = 0;
result = ncache_adderesult(fctx->rmessage, result = ncache_adderesult(fctx->rmessage, fctx->cache, node,
fctx->res->view->cachedb, node,
covers, now, ttl, covers, now, ttl,
ardataset, &eresult); ardataset, &eresult);
if (result != ISC_R_SUCCESS) if (result != ISC_R_SUCCESS)
@ -2621,21 +2628,17 @@ validated(isc_task_t *task, isc_event_t *event) {
* rdatasets to the first event on the fetch * rdatasets to the first event on the fetch
* event list. * event list.
*/ */
result = dns_db_findnode(fctx->res->view->cachedb, result = dns_db_findnode(fctx->cache, vevent->name, ISC_TRUE, &node);
vevent->name, ISC_TRUE, &node);
if (result != ISC_R_SUCCESS) if (result != ISC_R_SUCCESS)
goto noanswer_response; goto noanswer_response;
result = dns_db_addrdataset(fctx->res->view->cachedb, result = dns_db_addrdataset(fctx->cache, node, NULL, now,
node, NULL, now, vevent->rdataset, 0, ardataset);
vevent->rdataset, 0,
ardataset);
if (result != ISC_R_SUCCESS && if (result != ISC_R_SUCCESS &&
result != DNS_R_UNCHANGED) result != DNS_R_UNCHANGED)
goto noanswer_response; goto noanswer_response;
if (vevent->sigrdataset != NULL) { if (vevent->sigrdataset != NULL) {
result = dns_db_addrdataset(fctx->res->view->cachedb, result = dns_db_addrdataset(fctx->cache, node, NULL, now,
node, NULL, now,
vevent->sigrdataset, 0, vevent->sigrdataset, 0,
asigrdataset); asigrdataset);
if (result != ISC_R_SUCCESS && if (result != ISC_R_SUCCESS &&
@ -2680,7 +2683,7 @@ validated(isc_task_t *task, isc_event_t *event) {
hevent->result = eresult; hevent->result = eresult;
dns_name_copy(vevent->name, dns_name_copy(vevent->name,
dns_fixedname_name(&hevent->foundname), NULL); dns_fixedname_name(&hevent->foundname), NULL);
dns_db_attach(fctx->res->view->cachedb, &hevent->db); dns_db_attach(fctx->cache, &hevent->db);
hevent->node = node; hevent->node = node;
node = NULL; node = NULL;
clone_results(fctx); clone_results(fctx);
@ -2688,7 +2691,7 @@ validated(isc_task_t *task, isc_event_t *event) {
noanswer_response: noanswer_response:
if (node != NULL) if (node != NULL)
dns_db_detachnode(fctx->res->view->cachedb, &node); dns_db_detachnode(fctx->cache, &node);
fctx_done(fctx, result); fctx_done(fctx, result);
@ -2773,7 +2776,7 @@ cache_name(fetchctx_t *fctx, dns_name_t *name, isc_stdtime_t now) {
* Find or create the cache node. * Find or create the cache node.
*/ */
node = NULL; node = NULL;
result = dns_db_findnode(res->view->cachedb, name, ISC_TRUE, &node); result = dns_db_findnode(fctx->cache, name, ISC_TRUE, &node);
if (result != ISC_R_SUCCESS) if (result != ISC_R_SUCCESS)
return (result); return (result);
@ -2843,9 +2846,8 @@ cache_name(fetchctx_t *fctx, dns_name_t *name, isc_stdtime_t now) {
addedrdataset = ardataset; addedrdataset = ardataset;
else else
addedrdataset = NULL; addedrdataset = NULL;
result = dns_db_addrdataset(res->view->cachedb, result = dns_db_addrdataset(fctx->cache, node, NULL,
node, NULL, now, now, rdataset, 0,
rdataset, 0,
addedrdataset); addedrdataset);
if (result == DNS_R_UNCHANGED) if (result == DNS_R_UNCHANGED)
result = ISC_R_SUCCESS; result = ISC_R_SUCCESS;
@ -2856,7 +2858,7 @@ cache_name(fetchctx_t *fctx, dns_name_t *name, isc_stdtime_t now) {
addedrdataset = asigrdataset; addedrdataset = asigrdataset;
else else
addedrdataset = NULL; addedrdataset = NULL;
result = dns_db_addrdataset(res->view->cachedb, result = dns_db_addrdataset(fctx->cache,
node, NULL, now, node, NULL, now,
sigrdataset, 0, sigrdataset, 0,
addedrdataset); addedrdataset);
@ -2943,7 +2945,7 @@ cache_name(fetchctx_t *fctx, dns_name_t *name, isc_stdtime_t now) {
/* /*
* Now we can add the rdataset. * Now we can add the rdataset.
*/ */
result = dns_db_addrdataset(res->view->cachedb, result = dns_db_addrdataset(fctx->cache,
node, NULL, now, node, NULL, now,
rdataset, rdataset,
options, options,
@ -2993,7 +2995,7 @@ cache_name(fetchctx_t *fctx, dns_name_t *name, isc_stdtime_t now) {
fctx->attributes |= FCTX_ATTR_HAVEANSWER; fctx->attributes |= FCTX_ATTR_HAVEANSWER;
if (event != NULL) { if (event != NULL) {
event->result = eresult; event->result = eresult;
dns_db_attach(res->view->cachedb, adbp); dns_db_attach(fctx->cache, adbp);
*anodep = node; *anodep = node;
node = NULL; node = NULL;
clone_results(fctx); clone_results(fctx);
@ -3001,7 +3003,7 @@ cache_name(fetchctx_t *fctx, dns_name_t *name, isc_stdtime_t now) {
} }
if (node != NULL) if (node != NULL)
dns_db_detachnode(res->view->cachedb, &node); dns_db_detachnode(fctx->cache, &node);
return (result); return (result);
} }
@ -3200,8 +3202,7 @@ ncache_message(fetchctx_t *fctx, dns_rdatatype_t covers, isc_stdtime_t now) {
event = NULL; event = NULL;
node = NULL; node = NULL;
result = dns_db_findnode(res->view->cachedb, name, ISC_TRUE, result = dns_db_findnode(fctx->cache, name, ISC_TRUE, &node);
&node);
if (result != ISC_R_SUCCESS) if (result != ISC_R_SUCCESS)
goto unlock; goto unlock;
@ -3215,7 +3216,7 @@ ncache_message(fetchctx_t *fctx, dns_rdatatype_t covers, isc_stdtime_t now) {
covers == dns_rdatatype_any) covers == dns_rdatatype_any)
ttl = 0; ttl = 0;
result = ncache_adderesult(fctx->rmessage, res->view->cachedb, node, result = ncache_adderesult(fctx->rmessage, fctx->cache, node,
covers, now, ttl, ardataset, &eresult); covers, now, ttl, ardataset, &eresult);
if (result != ISC_R_SUCCESS) if (result != ISC_R_SUCCESS)
goto unlock; goto unlock;
@ -3224,7 +3225,7 @@ ncache_message(fetchctx_t *fctx, dns_rdatatype_t covers, isc_stdtime_t now) {
fctx->attributes |= FCTX_ATTR_HAVEANSWER; fctx->attributes |= FCTX_ATTR_HAVEANSWER;
if (event != NULL) { if (event != NULL) {
event->result = eresult; event->result = eresult;
dns_db_attach(res->view->cachedb, adbp); dns_db_attach(fctx->cache, adbp);
*anodep = node; *anodep = node;
node = NULL; node = NULL;
clone_results(fctx); clone_results(fctx);
@ -3235,7 +3236,7 @@ ncache_message(fetchctx_t *fctx, dns_rdatatype_t covers, isc_stdtime_t now) {
UNLOCK(&res->buckets[fctx->bucketnum].lock); UNLOCK(&res->buckets[fctx->bucketnum].lock);
if (node != NULL) if (node != NULL)
dns_db_detachnode(res->view->cachedb, &node); dns_db_detachnode(fctx->cache, &node);
return (result); return (result);
} }
@ -4073,7 +4074,7 @@ resquery_response(isc_task_t *task, isc_event_t *event) {
/* /*
* Remember that they don't like EDNS0. * Remember that they don't like EDNS0.
*/ */
dns_adb_changeflags(fctx->res->view->adb, dns_adb_changeflags(fctx->adb,
query->addrinfo, query->addrinfo,
DNS_FETCHOPT_NOEDNS0, DNS_FETCHOPT_NOEDNS0,
DNS_FETCHOPT_NOEDNS0); DNS_FETCHOPT_NOEDNS0);
@ -4129,7 +4130,7 @@ resquery_response(isc_task_t *task, isc_event_t *event) {
* Remember that they don't like EDNS0. * Remember that they don't like EDNS0.
*/ */
dns_adb_changeflags( dns_adb_changeflags(
fctx->res->view->adb, fctx->adb,
query->addrinfo, query->addrinfo,
DNS_FETCHOPT_NOEDNS0, DNS_FETCHOPT_NOEDNS0,
DNS_FETCHOPT_NOEDNS0); DNS_FETCHOPT_NOEDNS0);
@ -4157,7 +4158,7 @@ resquery_response(isc_task_t *task, isc_event_t *event) {
/* /*
* Remember that they don't like EDNS0. * Remember that they don't like EDNS0.
*/ */
dns_adb_changeflags(fctx->res->view->adb, dns_adb_changeflags(fctx->adb,
query->addrinfo, query->addrinfo,
DNS_FETCHOPT_NOEDNS0, DNS_FETCHOPT_NOEDNS0,
DNS_FETCHOPT_NOEDNS0); DNS_FETCHOPT_NOEDNS0);
@ -4241,7 +4242,7 @@ resquery_response(isc_task_t *task, isc_event_t *event) {
/* /*
* Remember that they don't like EDNS0. * Remember that they don't like EDNS0.
*/ */
dns_adb_changeflags(fctx->res->view->adb, dns_adb_changeflags(fctx->adb,
query->addrinfo, query->addrinfo,
DNS_FETCHOPT_NOEDNS0, DNS_FETCHOPT_NOEDNS0,
DNS_FETCHOPT_NOEDNS0); DNS_FETCHOPT_NOEDNS0);
@ -4297,7 +4298,7 @@ resquery_response(isc_task_t *task, isc_event_t *event) {
if (fctx->res->lame_ttl != 0 && !ISFORWARDER(query->addrinfo) && if (fctx->res->lame_ttl != 0 && !ISFORWARDER(query->addrinfo) &&
is_lame(fctx)) { is_lame(fctx)) {
log_lame(fctx, query->addrinfo); log_lame(fctx, query->addrinfo);
dns_adb_marklame(fctx->res->view->adb, query->addrinfo, dns_adb_marklame(fctx->adb, query->addrinfo,
&fctx->domain, now + fctx->res->lame_ttl); &fctx->domain, now + fctx->res->lame_ttl);
broken_server = ISC_TRUE; broken_server = ISC_TRUE;
keep_trying = ISC_TRUE; keep_trying = ISC_TRUE;

View File

@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: view.c,v 1.98 2001/03/26 21:33:00 bwelling Exp $ */ /* $Id: view.c,v 1.99 2001/04/11 20:37:45 bwelling Exp $ */
#include <config.h> #include <config.h>
@ -1093,3 +1093,21 @@ dns_view_dumpdbtostream(dns_view_t *view, FILE *fp) {
#endif #endif
return (ISC_R_SUCCESS); return (ISC_R_SUCCESS);
} }
isc_result_t
dns_view_flushcache(dns_view_t *view) {
isc_result_t result;
REQUIRE(DNS_VIEW_VALID(view));
if (view->cachedb == NULL)
return (ISC_R_SUCCESS);
result = dns_cache_flush(view->cache);
if (result != ISC_R_SUCCESS)
return (result);
dns_db_detach(&view->cachedb);
dns_cache_attachdb(view->cache, &view->cachedb);
dns_adb_flush(view->adb);
return (ISC_R_SUCCESS);
}