From: bert hubert Date: Sat, 22 Mar 2014 20:07:59 +0000 (+0100) Subject: fix up compilation against older boost w/o loss of functionality X-Git-Tag: rec-3.6.0-rc1~113 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=15c01debce267a442e136ea34dca190c1357c35b;p=thirdparty%2Fpdns.git fix up compilation against older boost w/o loss of functionality --- diff --git a/pdns/dnsreplay.cc b/pdns/dnsreplay.cc index 04cbfe3ab2..a4a64fc60f 100644 --- a/pdns/dnsreplay.cc +++ b/pdns/dnsreplay.cc @@ -21,6 +21,7 @@ There is one central object, which has (when complete) What to do with timeouts. We keep around at most 65536 outstanding answers. */ + /* mental_clock=0; for(;;) { @@ -97,11 +98,8 @@ const struct timeval operator*(float fact, const struct timeval& rhs) return ret; } -bool g_pleaseQuit; -void pleaseQuitHandler(int) -{ - g_pleaseQuit=true; -} + + class DNSIDManager : public boost::noncopyable { @@ -110,6 +108,7 @@ public: { for(unsigned int i=0; i < 65536; ++i) d_available.push_back(i); + } uint16_t peakID() @@ -141,31 +140,6 @@ private: } s_idmanager; -void setSocketBuffer(int fd, int optname, uint32_t size) -{ - uint32_t psize=0; - socklen_t len=sizeof(psize); - - if(!getsockopt(fd, SOL_SOCKET, optname, (char*)&psize, &len) && psize > size) { - cerr<<"Not decreasing socket buffer size from "< qids_t; qids_t qids; + + bool g_throttled; unsigned int s_questions, s_origanswers, s_weanswers, s_wetimedout, s_perfect, s_mostly, s_origtimedout; @@ -200,6 +176,7 @@ unsigned int s_webetter, s_origbetter, s_norecursionavailable; unsigned int s_weunmatched, s_origunmatched; unsigned int s_wednserrors, s_origdnserrors, s_duplicates; + double DiffTime(const struct timeval& first, const struct timeval& second) { int seconds=second.tv_sec - first.tv_sec; @@ -283,60 +260,16 @@ bool isRootReferral(const MOADNSParser::answers_t& answers) return ok; } -vector flightTimes; -void accountFlightTime(qids_t::const_iterator iter) -{ - if(flightTimes.empty()) - flightTimes.resize(2050); - - struct timeval now; - gettimeofday(&now, 0); - unsigned int mdiff = 1000*DiffTime(iter->d_resentTime, now); - if(mdiff > flightTimes.size()-2) - mdiff= flightTimes.size()-1; - - flightTimes[mdiff]++; -} - -uint64_t countLessThan(unsigned int msec) -{ - uint64_t ret=0; - for(unsigned int i = 0 ; i < msec && i < flightTimes.size() ; ++i) { - ret += flightTimes[i]; - } - return ret; -} - -void emitFlightTimes() +void measureResultAndClean(const QuestionIdentifier& qi) { - uint64_t totals = countLessThan(flightTimes.size()); - unsigned int limits[]={1, 2, 3, 4, 5, 10, 20, 30, 40, 50, 100, 200, 500, 1000, flightTimes.size()}; - uint64_t sofar=0; - cout.setf(std::ios::fixed); - cout.precision(2); - for(unsigned int i =0 ; i < sizeof(limits)/sizeof(limits[0]); ++i) { - if(limits[i]!=flightTimes.size()) - cout<<"Within "< canonicOrig, canonicNew; compactAnswerSet(qd.d_origAnswers, canonicOrig); compactAnswerSet(qd.d_newAnswers, canonicNew); if(!g_quiet) { - cout<d_qi; + QuestionData qd=*found; + qd.d_newAnswers=mdp.d_answers; qd.d_newRcode=mdp.d_header.rcode; idindex.replace(found, qd); if(qd.d_origRcode!=-1) { - qids_t::const_iterator iter= qids.project<0>(found); - measureResultAndClean(iter); + // cout<<"Removing entry "<first<<", is done [in socket]"<qr) { // this is to stress out the reference server with all the pain - qd.d_assignedID = s_idmanager.getID(); + if(!dh->qr) { + qd.d_assignedID = s_idmanager.peakID(); uint16_t tmp=dh->id; dh->id=htons(qd.d_assignedID); - s_socket->sendTo((const char*)pr.d_payload, pr.d_len, remote); + s_socket->sendTo(string(pr.d_payload, pr.d_payload + pr.d_len), remote); sent=true; dh->id=tmp; } MOADNSParser mdp((const char*)pr.d_payload, pr.d_len); QuestionIdentifier qi=QuestionIdentifier::create(pr.getSource(), pr.getDest(), mdp); - + if(!mdp.d_header.qr) { s_questions++; if(qids.count(qi)) { if(!g_quiet) - cout<<"Saw an exact duplicate question in PCAP "<(); - signal(SIGINT, pleaseQuitHandler); float speedup=g_vm["speedup"].as(); g_timeoutMsec=g_vm["timeout-msec"].as(); @@ -671,9 +610,7 @@ try s_socket= new Socket(InterNetwork, Datagram); s_socket->setNonBlocking(); - setSocketReceiveBuffer(s_socket->getHandle(), 2000000); - setSocketSendBuffer(s_socket->getHandle(), 2000000); - + ComboAddress remote(g_vm["target-ip"].as(), g_vm["target-port"].as()); @@ -688,10 +625,6 @@ try unsigned int count=0; for(;;) { - if(g_pleaseQuit) { - cerr<<"Interrupted from terminal"<getTid()<<"] dropping UDP query from "<