From: Otto Moerbeek Date: Wed, 10 Jun 2020 08:23:53 +0000 (+0200) Subject: Better error handling: return a bool and let caller decide. X-Git-Tag: rec-4.4.0-beta1~56^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b3dd32d2c2d997ef30c57d76787db366768b6738;p=thirdparty%2Fpdns.git Better error handling: return a bool and let caller decide. --- diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 0fcb702b6a..0f78ead18a 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -4711,8 +4711,11 @@ try t_allowFrom = g_initialAllowFrom; t_udpclientsocks = std::unique_ptr(new UDPClientSocks()); t_tcpClientCounts = std::unique_ptr(new tcpClientCounts_t()); + if (threadInfo.isHandler) { - primeHints(); + if (!primeHints()) { + throw PDNSException("Priming cache failed, stopping"); + } g_log< 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>(), vector>(), false); // and stuff in the cache + return true; } LuaConfigItems::LuaConfigItems() diff --git a/pdns/reczones.cc b/pdns/reczones.cc index 16d28b7101..f57be640d2 100644 --- a/pdns/reczones.cc +++ b/pdns/reczones.cc @@ -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<doWipeCache(g_rootdnsname, false, QType::NS); s_RC->replace(time(0), g_rootdnsname, QType(QType::NS), nsset, vector>(), vector>(), false, boost::none, boost::none, validationState); // and stuff in the cache + return true; } diff --git a/pdns/syncres.hh b/pdns/syncres.hh index 405a24c25d..6eaf54b797 100644 --- a/pdns/syncres.hh +++ b/pdns/syncres.hh @@ -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;