]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Better error handling: return a bool and let caller decide.
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 10 Jun 2020 08:23:53 +0000 (10:23 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Fri, 3 Jul 2020 08:27:19 +0000 (10:27 +0200)
pdns/pdns_recursor.cc
pdns/recursordist/test-syncres_cc.cc
pdns/reczones.cc
pdns/syncres.hh

index 0fcb702b6aff3e82636d22b93abe290851a5c768..0f78ead18a6acfc60289256073c8f96bf63d6e7c 100644 (file)
@@ -4711,8 +4711,11 @@ try
   t_allowFrom = g_initialAllowFrom;
   t_udpclientsocks = std::unique_ptr<UDPClientSocks>(new UDPClientSocks());
   t_tcpClientCounts = std::unique_ptr<tcpClientCounts_t>(new tcpClientCounts_t());
+
   if (threadInfo.isHandler) {
-    primeHints();
+    if (!primeHints()) {
+      throw PDNSException("Priming cache failed, stopping");
+    }
     g_log<<Logger::Warning<<"Done priming cache with root hints"<<endl;
   }
 
index c3d7af8ef55d8ed6f8c4cea2f817c85b1f9523b2..af352b31eb18c9e0134c7ee2e58dc9def4368fd2 100644 (file)
@@ -44,7 +44,7 @@ int asyncresolve(const ComboAddress& ip, const DNSName& domain, int type, bool d
 
 #include "root-addresses.hh"
 
-void primeHints(void)
+bool primeHints(void)
 {
   vector<DNSRecord> nsset;
   if (!s_RC)
@@ -79,6 +79,7 @@ void primeHints(void)
     nsset.push_back(nsrr);
   }
   s_RC->replace(time(nullptr), g_rootdnsname, QType(QType::NS), nsset, vector<std::shared_ptr<RRSIGRecordContent>>(), vector<std::shared_ptr<DNSRecord>>(), false); // and stuff in the cache
+  return true;
 }
 
 LuaConfigItems::LuaConfigItems()
index 16d28b7101ac5b61a2a25a32d54fb9bd0aae635f..f57be640d2e80c31186e7ab72fc3655b6e5548cc 100644 (file)
@@ -42,7 +42,7 @@ static void insertIntoRootNSZones(const DNSName &name) {
   }
 }
 
-void primeHints(void)
+bool primeHints(void)
 {
   // prime root cache
   const vState validationState = Insecure;
@@ -121,22 +121,22 @@ void primeHints(void)
       }
     }
     if (SyncRes::s_doIPv4 && !SyncRes::s_doIPv6 && !reachableA) {
-      g_log<<Logger::Critical<<"Running IPv4 only but no IPv4 root hints, stopping"<<endl;
-      // XXX exit() trips an exception in ~ThreadInfo, to be investigated
-      _exit(99);
+      g_log<<Logger::Error<<"Running IPv4 only but no IPv4 root hints"<<endl;
+      return false;
     }
     if (!SyncRes::s_doIPv4 && SyncRes::s_doIPv6 && !reachableAAAA) {
-      g_log<<Logger::Critical<<"Running IPv6 only but no IPv6 root hints, stopping"<<endl;
-      _exit(99);
+      g_log<<Logger::Error<<"Running IPv6 only but no IPv6 root hints"<<endl;
+      return false;
     }
     if (SyncRes::s_doIPv4 && SyncRes::s_doIPv6 && !reachableA && !reachableAAAA) {
-      g_log<<Logger::Critical<<"No valid root hints, stopping"<<endl;
-      _exit(99);
+      g_log<<Logger::Error<<"No valid root hints"<<endl;
+      return false;
     }
   }
 
   s_RC->doWipeCache(g_rootdnsname, false, QType::NS);
   s_RC->replace(time(0), g_rootdnsname, QType(QType::NS), nsset, vector<std::shared_ptr<RRSIGRecordContent>>(), vector<std::shared_ptr<DNSRecord>>(), false, boost::none, boost::none, validationState); // and stuff in the cache
+  return true;
 }
 
 
index 405a24c25d619a1e47e08882ee8f15f94721d83c..6eaf54b797ac4dc481693ec8f88b3cf39c54ce37 100644 (file)
@@ -1108,7 +1108,7 @@ uint64_t* pleaseWipeCache(const DNSName& canon, bool subtree=false, uint16_t qty
 uint64_t* pleaseWipePacketCache(const DNSName& canon, bool subtree, uint16_t qtype=0xffff);
 uint64_t* pleaseWipeAndCountNegCache(const DNSName& canon, bool subtree=false);
 void doCarbonDump(void*);
-void primeHints(void);
+bool primeHints(void);
 void primeRootNSZones(bool, unsigned int depth);
 
 extern __thread struct timeval g_now;