]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
auth-4.5.x: try to reload rejected zones in bind-backend once every bind-check-interval 10778/head
authorKees Monshouwer <mind04@monshouwer.org>
Tue, 21 Sep 2021 18:25:35 +0000 (20:25 +0200)
committermind04 <mind04@monshouwer.org>
Wed, 29 Sep 2021 13:30:17 +0000 (15:30 +0200)
modules/bindbackend/bindbackend2.cc

index 669d78e99fafd0325a6c3292c81f35f28a2fcc5d..f97ce6f81000b7319b683a4fe3e6ce9ced818902 100644 (file)
@@ -1041,12 +1041,12 @@ void Bind2Backend::queueReloadAndStore(unsigned int id)
   try {
     if (!safeGetBBDomainInfo(id, &bbold))
       return;
+    bbold.d_checknow = false;
     BB2DomainInfo bbnew(bbold);
     /* make sure that nothing will be able to alter the existing records,
        we will load them from the zone file instead */
     bbnew.d_records = LookButDontTouch<recordstorage_t>();
     parseZoneFile(&bbnew);
-    bbnew.d_checknow = false;
     bbnew.d_wasRejectedLastReload = false;
     safePutBBDomainInfo(bbnew);
     g_log << Logger::Warning << "Zone '" << bbnew.d_name << "' (" << bbnew.d_filename << ") reloaded" << endl;
@@ -1056,6 +1056,7 @@ void Bind2Backend::queueReloadAndStore(unsigned int id)
     msg << " error at " + nowTime() + " parsing '" << bbold.d_name << "' from file '" << bbold.d_filename << "': " << ae.reason;
     g_log << Logger::Warning << " error parsing '" << bbold.d_name << "' from file '" << bbold.d_filename << "': " << ae.reason << endl;
     bbold.d_status = msg.str();
+    bbold.d_lastcheck = time(nullptr);
     bbold.d_wasRejectedLastReload = true;
     safePutBBDomainInfo(bbold);
   }
@@ -1064,6 +1065,7 @@ void Bind2Backend::queueReloadAndStore(unsigned int id)
     msg << " error at " + nowTime() + " parsing '" << bbold.d_name << "' from file '" << bbold.d_filename << "': " << ae.what();
     g_log << Logger::Warning << " error parsing '" << bbold.d_name << "' from file '" << bbold.d_filename << "': " << ae.what() << endl;
     bbold.d_status = msg.str();
+    bbold.d_lastcheck = time(nullptr);
     bbold.d_wasRejectedLastReload = true;
     safePutBBDomainInfo(bbold);
   }
@@ -1179,11 +1181,6 @@ void Bind2Backend::lookup(const QType& qtype, const DNSName& qname, int zoneId,
   d_handle.qtype = qtype;
   d_handle.domain = std::move(domain);
 
-  if (!bbd.d_loaded) {
-    d_handle.reset();
-    throw DBException("Zone for '" + d_handle.domain.toLogString() + "' in '" + bbd.d_filename + "' temporarily not available (file missing, or master dead)"); // fsck
-  }
-
   if (!bbd.current()) {
     g_log << Logger::Warning << "Zone '" << d_handle.domain << "' (" << bbd.d_filename << ") needs reloading" << endl;
     queueReloadAndStore(bbd.d_id);
@@ -1191,6 +1188,11 @@ void Bind2Backend::lookup(const QType& qtype, const DNSName& qname, int zoneId,
       throw DBException("Zone '" + bbd.d_name.toLogString() + "' (" + bbd.d_filename + ") gone after reload"); // if we don't throw here, we crash for some reason
   }
 
+  if (!bbd.d_loaded) {
+    d_handle.reset();
+    throw DBException("Zone for '" + d_handle.domain.toLogString() + "' in '" + bbd.d_filename + "' not loaded (file missing, corrupt or master dead)"); // fsck
+  }
+
   d_handle.d_records = bbd.d_records.get();
 
   if (d_handle.d_records->empty())