Skip to content

Commit 93dea82

Browse files
committed
Skip zone cache refresh logic if disabled.
Signed-off-by: Miod Vallat <miod.vallat@powerdns.com>
1 parent 8e748e8 commit 93dea82

1 file changed

Lines changed: 33 additions & 28 deletions

File tree

pdns/auth-main.cc

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -966,19 +966,21 @@ static void mainthread()
966966

967967
// Setup the zone cache
968968
g_zoneCache.setRefreshInterval(::arg().asNum("zone-cache-refresh-interval"));
969-
try {
970-
UeberBackend B;
971-
B.updateZoneCache();
972-
}
973-
catch (PDNSException& e) {
974-
SLOG(g_log << Logger::Error << "PDNSException while filling the zone cache: " << e.reason << endl,
975-
slog->error(Logr::Error, e.reason, "PDNSException while filling the zone cache"));
976-
exit(1);
977-
}
978-
catch (std::exception& e) {
979-
SLOG(g_log << Logger::Error << "STL Exception while filling the zone cache: " << e.what() << endl,
980-
slog->error(Logr::Error, e.what(), "STL Exception while filling the zone cache"));
981-
exit(1);
969+
if (g_zoneCache.getRefreshInterval() != 0) {
970+
try {
971+
UeberBackend B;
972+
B.updateZoneCache();
973+
}
974+
catch (PDNSException& e) {
975+
SLOG(g_log << Logger::Error << "PDNSException while filling the zone cache: " << e.reason << endl,
976+
slog->error(Logr::Error, e.reason, "PDNSException while filling the zone cache"));
977+
exit(1);
978+
}
979+
catch (std::exception& e) {
980+
SLOG(g_log << Logger::Error << "STL Exception while filling the zone cache: " << e.what() << endl,
981+
slog->error(Logr::Error, e.what(), "STL Exception while filling the zone cache"));
982+
exit(1);
983+
}
982984
}
983985

984986
// NOW SAFE TO CREATE THREADS!
@@ -1015,23 +1017,26 @@ static void mainthread()
10151017
uint32_t secpollSince = 0;
10161018
uint32_t zoneCacheUpdateSince = 0;
10171019
for (;;) {
1018-
const uint32_t sleeptime = g_zoneCache.getRefreshInterval() == 0 ? secpollInterval : std::min(secpollInterval, g_zoneCache.getRefreshInterval());
1020+
auto zoneCacheRefresh = g_zoneCache.getRefreshInterval();
1021+
const uint32_t sleeptime = zoneCacheRefresh == 0 ? secpollInterval : std::min(secpollInterval, zoneCacheRefresh);
10191022
sleep(sleeptime); // if any signals arrive, we might run more often than expected.
10201023

1021-
zoneCacheUpdateSince += sleeptime;
1022-
if (zoneCacheUpdateSince >= g_zoneCache.getRefreshInterval()) {
1023-
try {
1024-
UeberBackend B;
1025-
B.updateZoneCache();
1026-
zoneCacheUpdateSince = 0;
1027-
}
1028-
catch (PDNSException& e) {
1029-
SLOG(g_log << Logger::Error << "PDNSException while updating zone cache: " << e.reason << endl,
1030-
slog->error(Logr::Error, e.reason, "PDNSException while updating the zone cache"));
1031-
}
1032-
catch (std::exception& e) {
1033-
SLOG(g_log << Logger::Error << "STL Exception while updating zone cache: " << e.what() << endl,
1034-
slog->error(Logr::Error, e.what(), "STL Exception while updating the zone cache"));
1024+
if (zoneCacheRefresh != 0) {
1025+
zoneCacheUpdateSince += sleeptime;
1026+
if (zoneCacheUpdateSince >= zoneCacheRefresh) {
1027+
try {
1028+
UeberBackend B;
1029+
B.updateZoneCache();
1030+
zoneCacheUpdateSince = 0;
1031+
}
1032+
catch (PDNSException& e) {
1033+
SLOG(g_log << Logger::Error << "PDNSException while updating zone cache: " << e.reason << endl,
1034+
slog->error(Logr::Error, e.reason, "PDNSException while updating the zone cache"));
1035+
}
1036+
catch (std::exception& e) {
1037+
SLOG(g_log << Logger::Error << "STL Exception while updating zone cache: " << e.what() << endl,
1038+
slog->error(Logr::Error, e.what(), "STL Exception while updating the zone cache"));
1039+
}
10351040
}
10361041
}
10371042

0 commit comments

Comments
 (0)