Skip to content

Commit 3cd61b1

Browse files
committed
Skip zone cache refresh logic if disabled.
Signed-off-by: Miod Vallat <miod.vallat@powerdns.com>
1 parent 391c7f8 commit 3cd61b1

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
@@ -967,19 +967,21 @@ static void mainthread()
967967

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

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

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

0 commit comments

Comments
 (0)