From: bert hubert Date: Tue, 16 Aug 2016 10:03:34 +0000 (+0200) Subject: fix up AtomicCounter being used unitialized here and there, plus possibly fix clang... X-Git-Tag: rec-4.0.2~27^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c3064e576d57d766a242b3299af8164ceeb27bc1;p=thirdparty%2Fpdns.git fix up AtomicCounter being used unitialized here and there, plus possibly fix clang compilation --- diff --git a/pdns/packetcache.cc b/pdns/packetcache.cc index 87a6632da2..3b16059dd2 100644 --- a/pdns/packetcache.cc +++ b/pdns/packetcache.cc @@ -34,6 +34,7 @@ extern StatBag S; PacketCache::PacketCache() { + d_ops=0; d_maps.resize(1024); for(auto& mc : d_maps) { pthread_rwlock_init(&mc.d_mut, 0); diff --git a/pdns/responsestats.cc b/pdns/responsestats.cc index b61aa03c13..c98db9ad4e 100644 --- a/pdns/responsestats.cc +++ b/pdns/responsestats.cc @@ -8,7 +8,7 @@ #include "dnsparser.hh" -ResponseStats::ResponseStats() : d_qtypecounters(65536) +ResponseStats::ResponseStats() : d_qtypecounters(new std::atomic[65536]) { d_sizecounters.push_back(make_pair(20,0)); d_sizecounters.push_back(make_pair(40,0)); @@ -21,7 +21,7 @@ ResponseStats::ResponseStats() : d_qtypecounters(65536) d_sizecounters.push_back(make_pair(std::numeric_limits::max(),0)); } -ResponseStats g_rs = ResponseStats(); +ResponseStats g_rs; static bool pcomp(const pair&a , const pair&b) { @@ -42,7 +42,7 @@ map ResponseStats::getQTypeResponseCounts() { map ret; uint64_t count; - for(unsigned int i = 0 ; i < d_qtypecounters.size() ; ++i) { + for(unsigned int i = 0 ; i < 65535 ; ++i) { count= d_qtypecounters[i]; if(count) ret[i]=count; diff --git a/pdns/responsestats.hh b/pdns/responsestats.hh index dfb04a86ca..092c2b6386 100644 --- a/pdns/responsestats.hh +++ b/pdns/responsestats.hh @@ -14,7 +14,7 @@ public: string getQTypeReport(); private: - vector d_qtypecounters; + boost::scoped_array> d_qtypecounters; typedef vector > sizecounters_t; sizecounters_t d_sizecounters; }; diff --git a/pdns/signingpipe.cc b/pdns/signingpipe.cc index 71d0f997ec..3cfbc13aaa 100644 --- a/pdns/signingpipe.cc +++ b/pdns/signingpipe.cc @@ -71,7 +71,7 @@ catch(...) { } ChunkedSigningPipe::ChunkedSigningPipe(const DNSName& signerName, bool mustSign, const string& servers, unsigned int workers) - : d_queued(0), d_outstanding(0), d_numworkers(workers), d_submitted(0), d_signer(signerName), + : d_signed(0), d_queued(0), d_outstanding(0), d_numworkers(workers), d_submitted(0), d_signer(signerName), d_maxchunkrecords(100), d_tids(d_numworkers), d_mustSign(mustSign), d_final(false) { d_rrsetToSign = new rrset_t; diff --git a/pdns/signingpipe.hh b/pdns/signingpipe.hh index 01b030f183..2263ffdb3d 100644 --- a/pdns/signingpipe.hh +++ b/pdns/signingpipe.hh @@ -24,7 +24,7 @@ public: bool submit(const DNSResourceRecord& rr); chunk_t getChunk(bool final=false); - AtomicCounter d_signed; + std::atomic d_signed; int d_queued; int d_outstanding; unsigned int getReady(); diff --git a/pdns/test-misc_hh.cc b/pdns/test-misc_hh.cc index aeadaae039..f3fa17c5f4 100644 --- a/pdns/test-misc_hh.cc +++ b/pdns/test-misc_hh.cc @@ -118,7 +118,7 @@ BOOST_AUTO_TEST_CASE(test_makeRelative) { } BOOST_AUTO_TEST_CASE(test_AtomicCounter) { - AtomicCounter ac; + AtomicCounter ac(0); ++ac; ++ac; BOOST_CHECK_EQUAL(ac, 2);