From 33494729133db95a611d5223666d0fd044cba74c Mon Sep 17 00:00:00 2001 From: Pieter Lexis Date: Sat, 20 Jan 2018 13:05:03 +0100 Subject: [PATCH] ixfrdist: switch to std::thread and some update interval fixes --- pdns/ixfrdist.cc | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/pdns/ixfrdist.cc b/pdns/ixfrdist.cc index 550151f4c..36db96d99 100644 --- a/pdns/ixfrdist.cc +++ b/pdns/ixfrdist.cc @@ -25,6 +25,7 @@ #include #include #include +#include #include "ixfr.hh" #include "ixfrutils.hh" #include "resolver.hh" @@ -81,7 +82,7 @@ void usage(po::options_description &desc) { cerr << desc << "\n"; } -void* updateThread(void*) { +void updateThread() { std::map lastCheck; // Initialize the serials we have @@ -102,7 +103,7 @@ void* updateThread(void*) { // Most likely, the directory does not exist. cerr<<"[INFO] "<d_st.refresh) { + if ((g_soas.find(domain) != g_soas.end() && now - lastCheck[domain] < g_soas[domain]->d_st.refresh) || // Only check if we have waited `refresh` seconds + (g_soas.find(domain) == g_soas.end() && now - lastCheck[domain] < 30)) { // Or if we could not get an update at all still, every 30 seconds continue; } string dir = g_workdir + "/" + domain.toString(); @@ -131,8 +133,8 @@ void* updateThread(void*) { } shared_ptr sr; try { - auto newSerial = getSerialFromMaster(g_master, domain, sr); // TODO TSIG lastCheck[domain] = now; + auto newSerial = getSerialFromMaster(g_master, domain, sr); // TODO TSIG if(g_soas.find(domain) != g_soas.end() && g_verbose) { cerr<<"[INFO] Got SOA Serial for "<d_st.serial; if (newSerial == g_soas[domain]->d_st.serial) { @@ -710,11 +712,9 @@ int main(int argc, char** argv) { // TODO read from urandom (perhaps getrandom(2)? dns_random_init("0123456789abcdef"); - pthread_t qtid; - cout<<"[INFO] IXFR distributor starting up!"<