Commit 2a37aa18 authored by Mark Andrews's avatar Mark Andrews
Browse files

507. [func] New functions dns_zone_flush(), dns_zt_flushanddetach()

                        and dns_view_flushanddetach().

 503 was incomplete.
parent 8a237427
507. [func] New functions dns_zone_flush(), dns_zt_flushanddetach()
and dns_view_flushanddetach().
506. [func] Do not fail to start on errors in zone files.
505. [bug] nsupdate was printing "unknown result code". [RT #373]
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: view.h,v 1.52 2000/09/05 03:35:24 marka Exp $ */
/* $Id: view.h,v 1.53 2000/10/05 06:39:24 marka Exp $ */
#ifndef DNS_VIEW_H
#define DNS_VIEW_H 1
......@@ -194,6 +194,21 @@ dns_view_detach(dns_view_t **viewp);
* *viewp is NULL.
*/
void
dns_view_flushanddetach(dns_view_t **viewp);
/*
* Detach '*viewp' from its view. If this was the last reference
* uncommited changed in zones will be flushed to disk.
*
* Requires:
*
* 'viewp' points to a valid dns_view_t *
*
* Ensures:
*
* *viewp is NULL.
*/
void
dns_view_weakattach(dns_view_t *source, dns_view_t **targetp);
/*
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: zone.h,v 1.77 2000/09/26 18:17:10 gson Exp $ */
/* $Id: zone.h,v 1.78 2000/10/05 06:39:25 marka Exp $ */
#ifndef DNS_ZONE_H
#define DNS_ZONE_H 1
......@@ -325,6 +325,15 @@ dns_zone_refresh(dns_zone_t *zone);
* 'zone' to be a valid zone.
*/
isc_result_t
dns_zone_flush(dns_zone_t *zone);
/*
* Write the zone to database if there are uncommited changes.
*
* Require:
* 'zone' to be a valid zone.
*/
isc_result_t
dns_zone_dump(dns_zone_t *zone);
/*
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: zt.h,v 1.22 2000/08/14 19:52:20 gson Exp $ */
/* $Id: zt.h,v 1.23 2000/10/05 06:39:26 marka Exp $ */
#ifndef DNS_ZT_H
#define DNS_ZT_H 1
......@@ -106,6 +106,17 @@ dns_zt_detach(dns_zt_t **ztp);
* '*ztp' to be valid
*/
void
dns_zt_flushanddetach(dns_zt_t **ztp);
/*
* Detach the given zonetable, if the reference count goes to zero the
* zonetable will be flushed and then freed. In either case 'ztp' is
* set to NULL.
*
* Requires:
* '*ztp' to be valid
*/
void
dns_zt_attach(dns_zt_t *zt, dns_zt_t **ztp);
/*
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: view.c,v 1.80 2000/09/25 17:46:39 bwelling Exp $ */
/* $Id: view.c,v 1.81 2000/10/05 06:39:20 marka Exp $ */
#include <config.h>
......@@ -287,8 +287,8 @@ dns_view_attach(dns_view_t *source, dns_view_t **targetp) {
*targetp = source;
}
void
dns_view_detach(dns_view_t **viewp) {
static void
view_flushanddetach(dns_view_t **viewp, isc_boolean_t flush) {
dns_view_t *view;
isc_boolean_t done = ISC_FALSE;
......@@ -307,7 +307,10 @@ dns_view_detach(dns_view_t **viewp) {
dns_adb_shutdown(view->adb);
if (!REQSHUTDOWN(view))
dns_requestmgr_shutdown(view->requestmgr);
dns_zt_detach(&view->zonetable);
if (flush)
dns_zt_flushanddetach(&view->zonetable);
else
dns_zt_detach(&view->zonetable);
done = all_done(view);
}
UNLOCK(&view->lock);
......@@ -318,6 +321,16 @@ dns_view_detach(dns_view_t **viewp) {
destroy(view);
}
void
dns_view_flushanddetach(dns_view_t **viewp) {
view_flushanddetach(viewp, ISC_TRUE);
}
void
dns_view_detach(dns_view_t **viewp) {
view_flushanddetach(viewp, ISC_FALSE);
}
void
dns_view_weakattach(dns_view_t *source, dns_view_t **targetp) {
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: zone.c,v 1.226 2000/10/03 05:47:45 marka Exp $ */
/* $Id: zone.c,v 1.227 2000/10/05 06:39:21 marka Exp $ */
#include <config.h>
......@@ -193,7 +193,7 @@ struct dns_zone {
#define DNS_ZONEFLG_REFRESH 0x00000001U /* refresh check in progress */
#define DNS_ZONEFLG_NEEDDUMP 0x00000002U /* zone need consolidation */
#define DNS_ZONEFLG_USEVC 0x00000004U /* use tcp for refresh query */
/* #define DNS_ZONEFLG_UNUSED 0x00000008U */ /* unused */
#define DNS_ZONEFLG_DUMPING 0x00000008U /* a dump is in progress */
/* #define DNS_ZONEFLG_UNUSED 0x00000010U */ /* unused */
#define DNS_ZONEFLG_LOADED 0x00000020U /* database has loaded */
#define DNS_ZONEFLG_EXITING 0x00000040U /* zone is being destroyed */
......@@ -961,6 +961,7 @@ zone_postload(dns_zone_t *zone, dns_db_t *db, isc_time_t loadtime,
unsigned int nscount = 0;
isc_uint32_t serial, refresh, retry, expire, minimum;
isc_stdtime_t now;
isc_boolean_t needdump = ISC_FALSE;
isc_stdtime_get(&now);
......@@ -1017,7 +1018,7 @@ zone_postload(dns_zone_t *zone, dns_db_t *db, isc_time_t loadtime,
"dns_journal_rollforward: %s",
dns_result_totext(result));
if (result == ISC_R_SUCCESS)
zone_needdump(zone, DNS_DUMP_DELAY);
needdump = ISC_TRUE;
}
/*
......@@ -1110,6 +1111,8 @@ zone_postload(dns_zone_t *zone, dns_db_t *db, isc_time_t loadtime,
zone->flags |= DNS_ZONEFLG_LOADED|DNS_ZONEFLG_NEEDNOTIFY;
}
result = ISC_R_SUCCESS;
if (needdump)
zone_needdump(zone, DNS_DUMP_DELAY);
if (!DNS_ZONE_FLAG(zone, DNS_ZONEFLG_EXITING))
(void) zone_settimer(zone, now);
return (result);
......@@ -1822,6 +1825,20 @@ dns_zone_refresh(dns_zone_t *zone) {
queue_soa_query(zone);
}
isc_result_t
dns_zone_flush(dns_zone_t *zone) {
isc_result_t result = ISC_R_SUCCESS;
REQUIRE(DNS_ZONE_VALID(zone));
LOCK(&zone->lock);
if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_NEEDDUMP))
result = zone_dump(zone);
UNLOCK(&zone->lock);
return (result);
}
isc_result_t
dns_zone_dump(dns_zone_t *zone) {
isc_result_t result;
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: zt.c,v 1.25 2000/08/13 23:51:53 gson Exp $ */
/* $Id: zt.c,v 1.26 2000/10/05 06:39:22 marka Exp $ */
#include <config.h>
......@@ -171,8 +171,14 @@ dns_zt_attach(dns_zt_t *zt, dns_zt_t **ztp) {
*ztp = zt;
}
void
dns_zt_detach(dns_zt_t **ztp) {
static isc_result_t
flush(dns_zone_t *zone, void *uap) {
UNUSED(uap);
return (dns_zone_flush(zone));
}
static void
zt_flushanddetach(dns_zt_t **ztp, isc_boolean_t need_flush) {
isc_boolean_t destroy = ISC_FALSE;
dns_zt_t *zt;
......@@ -190,6 +196,8 @@ dns_zt_detach(dns_zt_t **ztp) {
RWUNLOCK(&zt->rwlock, isc_rwlocktype_write);
if (destroy) {
if (need_flush)
(void)dns_zt_apply(zt, ISC_FALSE, flush, NULL);
dns_rbt_destroy(&zt->table);
isc_rwlock_destroy(&zt->rwlock);
zt->magic = 0;
......@@ -199,6 +207,16 @@ dns_zt_detach(dns_zt_t **ztp) {
*ztp = NULL;
}
void
dns_zt_flushanddetach(dns_zt_t **ztp) {
zt_flushanddetach(ztp, ISC_TRUE);
}
void
dns_zt_detach(dns_zt_t **ztp) {
zt_flushanddetach(ztp, ISC_FALSE);
}
isc_result_t
dns_zt_load(dns_zt_t *zt, isc_boolean_t stop) {
isc_result_t result;
......
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