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