From 23a6775f62deeee63e9f7927be387fecf23a8074 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= <ondrej@isc.org>
Date: Tue, 10 Dec 2019 10:02:09 +0100
Subject: [PATCH] Ensure all zone_settimer() calls are done on locked zone
(cherry picked from commit cf48e8eb326f824170f2069e5d5c33992b1783a4)
(cherry picked from commit 3bac7e98074643ff62582545e5840e4195517b07)
---
lib/dns/zone.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/lib/dns/zone.c b/lib/dns/zone.c
index e8cff77588..db837aae50 100644
--- a/lib/dns/zone.c
+++ b/lib/dns/zone.c
@@ -10291,7 +10291,9 @@ zone_maintenance(dns_zone_t *zone) {
default:
break;
}
+ LOCK_ZONE(zone);
zone_settimer(zone, &now);
+ UNLOCK_ZONE(zone);
}
void
@@ -13081,6 +13083,7 @@ zone_settimer(dns_zone_t *zone, isc_time_t *now) {
isc_result_t result;
REQUIRE(DNS_ZONE_VALID(zone));
+ REQUIRE(LOCKED_ZONE(zone));
ENTER;
if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_EXITING))
@@ -18405,6 +18408,7 @@ zone_rekey(dns_zone_t *zone) {
UNLOCK_ZONE(zone);
}
+ LOCK_ZONE(zone);
isc_time_settoepoch(&zone->refreshkeytime);
/*
@@ -18416,11 +18420,9 @@ zone_rekey(dns_zone_t *zone) {
isc_time_t timethen;
isc_stdtime_t then;
- LOCK_ZONE(zone);
DNS_ZONE_TIME_ADD(&timenow, zone->refreshkeyinterval,
&timethen);
zone->refreshkeytime = timethen;
- UNLOCK_ZONE(zone);
for (key = ISC_LIST_HEAD(dnskeys);
key != NULL;
@@ -18431,12 +18433,10 @@ zone_rekey(dns_zone_t *zone) {
continue;
DNS_ZONE_TIME_ADD(&timenow, then - now, &timethen);
- LOCK_ZONE(zone);
if (isc_time_compare(&timethen,
&zone->refreshkeytime) < 0) {
zone->refreshkeytime = timethen;
}
- UNLOCK_ZONE(zone);
}
zone_settimer(zone, &timenow);
@@ -18444,6 +18444,7 @@ zone_rekey(dns_zone_t *zone) {
isc_time_formattimestamp(&zone->refreshkeytime, timebuf, 80);
dns_zone_log(zone, ISC_LOG_INFO, "next key event: %s", timebuf);
}
+ UNLOCK_ZONE(zone);
done:
dns_diff_clear(&diff);
--
2.21.0