From: Erik Winkels Date: Fri, 26 Jan 2018 16:07:05 +0000 (+0100) Subject: Fix failure to start RPZIXFRTracker tracker thread. X-Git-Tag: rec-4.1.2~4^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ba1f9e67c1928be6ada1c0d87f83660f06a2a51f;p=thirdparty%2Fpdns.git Fix failure to start RPZIXFRTracker tracker thread. This is an initial commit and needs more work (but it's 17:07 on a Friday, so yeah...). (cherry picked from commit e9112b46b9d972aed25e1f1f9ec46253b6718d5c) --- diff --git a/pdns/rec-lua-conf.cc b/pdns/rec-lua-conf.cc index b73a384934..72eac5f00c 100644 --- a/pdns/rec-lua-conf.cc +++ b/pdns/rec-lua-conf.cc @@ -135,16 +135,22 @@ void loadRecursorLuaConfig(const std::string& fname, bool checkOnly) }); Lua.writeFunction("rpzMaster", [&lci, checkOnly](const string& master_, const string& zoneName, const boost::optional>>& options) { + + boost::optional defpol; + std::shared_ptr zone = std::make_shared(); + TSIGTriplet tt; + uint32_t refresh=0; + size_t maxReceivedXFRMBytes = 0; + uint16_t axfrTimeout = 20; + uint32_t maxTTL = std::numeric_limits::max(); + ComboAddress localAddress; + ComboAddress master(master_, 53); + DNSName domain(zoneName); + size_t zoneIdx; + std::shared_ptr sr; + try { - boost::optional defpol; - std::shared_ptr zone = std::make_shared(); - TSIGTriplet tt; - uint32_t refresh=0; std::string polName(zoneName); - size_t maxReceivedXFRMBytes = 0; - uint16_t axfrTimeout = 20; - uint32_t maxTTL = std::numeric_limits::max(); - ComboAddress localAddress; if(options) { auto& have = *options; size_t zoneSizeHint = 0; @@ -171,35 +177,52 @@ void loadRecursorLuaConfig(const std::string& fname, bool checkOnly) axfrTimeout = static_cast(boost::get(constGet(have, "axfrTimeout"))); } } - ComboAddress master(master_, 53); if (localAddress != ComboAddress() && localAddress.sin4.sin_family != master.sin4.sin_family) { // We were passed a localAddress, check if its AF matches the master's throw PDNSException("Master address("+master.toString()+") is not of the same Address Family as the local address ("+localAddress.toString()+")."); } - DNSName domain(zoneName); zone->setDomain(domain); zone->setName(polName); zone->setRefresh(refresh); - size_t zoneIdx = lci.dfe.addZone(zone); + zoneIdx = lci.dfe.addZone(zone); + } + catch(const std::exception& e) { + theL()<d_st.refresh=refresh; zone->setSerial(sr->d_st.serial); - - std::thread t(RPZIXFRTracker, master, DNSName(zoneName), defpol, maxTTL, zoneIdx, tt, sr, maxReceivedXFRMBytes * 1024 * 1024, localAddress, axfrTimeout); - t.detach(); } } catch(const std::exception& e) { - theL()< > > > > argvec_t; diff --git a/pdns/reczones.cc b/pdns/reczones.cc index 6f76419c88..f58239f0a2 100644 --- a/pdns/reczones.cc +++ b/pdns/reczones.cc @@ -320,14 +320,40 @@ string reloadAuthAndForwards() void RPZIXFRTracker(const ComboAddress& master, const DNSName& zoneName, boost::optional defpol, uint32_t maxTTL, size_t zoneIdx, const TSIGTriplet& tt, shared_ptr oursr, size_t maxReceivedBytes, const ComboAddress& localAddress, const uint16_t axfrTimeout) { - uint32_t refresh = oursr->d_st.refresh; + uint32_t refresh = 5; // FIXME properly init from somewhere + if (oursr != 0) { // FIXME replace with 'official' null check + refresh = oursr->d_st.refresh; + } + for(;;) { DNSRecord dr; dr.d_content=oursr; sleep(refresh); - - L<(dr)->d_st.serial< zone = std::make_shared(); + DNSName domain(zoneName); + zone->setDomain(domain); + zone->setName("FIXMECHANGEME"); + zone->setRefresh(refresh); + oursr=loadRPZFromServer(master, domain, zone, defpol, maxTTL, tt, maxReceivedBytes, localAddress); + refresh = oursr->d_st.refresh; + dr.d_content=oursr; + } + catch(const std::exception& e) { + theL()<(dr)->d_st.serial<, vector > > deltas; ComboAddress local(localAddress); @@ -335,7 +361,9 @@ void RPZIXFRTracker(const ComboAddress& master, const DNSName& zoneName, boost:: local = getQueryLocalAddress(master.sin4.sin_family, 0); try { - deltas = getIXFRDeltas(master, zoneName, dr, tt, &local, maxReceivedBytes); + if (oursr != 0) { // FIXME replace with 'official' null check + deltas = getIXFRDeltas(master, zoneName, dr, tt, &local, maxReceivedBytes); + } } catch(std::runtime_error& e ){ L<