From fefbb64a751f23c9dcf8bb1e62c6ed40a6a04fb2 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Tue, 4 Dec 2001 05:17:53 +0000 Subject: [PATCH] 1155. [func] Recover from master files being removed from under us. --- CHANGES | 3 +++ lib/dns/zone.c | 23 ++++++++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 4fdb54e74a..faf692b487 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +1155. [func] Recover from master files being removed from under + us. + 1154. [bug] When scanning interfaces skip the interface if address no address is configured. [RT #2176] diff --git a/lib/dns/zone.c b/lib/dns/zone.c index b137da87c9..101c6e77e1 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: zone.c,v 1.354 2001/11/30 01:59:25 gson Exp $ */ +/* $Id: zone.c,v 1.355 2001/12/04 05:17:53 marka Exp $ */ #include @@ -2222,6 +2222,7 @@ dump_done(void *arg, isc_result_t result) { switch (tresult) { case ISC_R_SUCCESS: case ISC_R_NOSPACE: + case ISC_R_NOTFOUND: dns_zone_log(zone, ISC_LOG_DEBUG(3), "dns_journal_compact: %s", dns_result_totext(tresult)); @@ -3420,7 +3421,12 @@ refresh_callback(isc_task_t *task, isc_event_t *event) { } else if (isc_serial_eq(soa.serial, zone->serial)) { if (zone->masterfile != NULL) { result = isc_file_settime(zone->masterfile, &now); - if (result != ISC_R_SUCCESS) + /* Someone removed the file from underneath us! */ + if (result == ISC_R_FILENOTFOUND) { + LOCK_ZONE(zone); + zone_needdump(zone, DNS_DUMP_DELAY); + UNLOCK_ZONE(zone); + } else if (result != ISC_R_SUCCESS) dns_zone_log(zone, ISC_LOG_ERROR, "refresh: could not set file " "modification time of '%s': %s", @@ -3945,6 +3951,13 @@ zone_settimer(dns_zone_t *zone, isc_time_t *now) { isc_time_compare(&zone->expiretime, &next) < 0) next = zone->expiretime; } + if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_NEEDDUMP) && + !DNS_ZONE_FLAG(zone, DNS_ZONEFLG_DUMPING)) { + INSIST(!isc_time_isepoch(&zone->dumptime)); + if (isc_time_isepoch(&next) || + isc_time_compare(&zone->dumptime, &next) < 0) + next = zone->dumptime; + } break; default: @@ -4857,7 +4870,11 @@ zone_xfrdone(dns_zone_t *zone, isc_result_t result) { zone->masterfile != NULL) result = isc_file_settime(zone->masterfile, &now); - if (result != ISC_R_SUCCESS) + /* Someone removed the file from underneath us! */ + if (result == ISC_R_FILENOTFOUND && + zone->masterfile != NULL) + zone_needdump(zone, DNS_DUMP_DELAY); + else if (result != ISC_R_SUCCESS) dns_zone_log(zone, ISC_LOG_ERROR, "transfer: could not set file " "modification time of '%s': %s",