]> granicus.if.org Git - pdns/commitdiff
fix up AtomicCounter being used unitialized here and there, plus possibly fix clang...
authorbert hubert <bert.hubert@powerdns.com>
Tue, 16 Aug 2016 10:03:34 +0000 (12:03 +0200)
committerbert hubert <bert.hubert@powerdns.com>
Tue, 16 Aug 2016 10:03:34 +0000 (12:03 +0200)
pdns/packetcache.cc
pdns/responsestats.cc
pdns/responsestats.hh
pdns/signingpipe.cc
pdns/signingpipe.hh
pdns/test-misc_hh.cc

index 87a6632da2f7f090b095ddc7cb7c20a97354c67e..3b16059dd2fe7d03de5adc2fe2dc986c1f09068b 100644 (file)
@@ -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);
index b61aa03c137a4d654fc25d8ebb676196b8fe9b6f..c98db9ad4edb1658ccb46c0ff0b62c6c9953cb6f 100644 (file)
@@ -8,7 +8,7 @@
 
 #include "dnsparser.hh"
 
-ResponseStats::ResponseStats() : d_qtypecounters(65536)
+ResponseStats::ResponseStats() :   d_qtypecounters(new std::atomic<unsigned long>[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<uint16_t>::max(),0));
 }
 
-ResponseStats g_rs = ResponseStats();
+ResponseStats g_rs;
 
 static bool pcomp(const pair<uint16_t, uint64_t>&a , const pair<uint16_t, uint64_t>&b)
 {
@@ -42,7 +42,7 @@ map<uint16_t, uint64_t> ResponseStats::getQTypeResponseCounts()
 {
   map<uint16_t, uint64_t> 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;
index dfb04a86ca3dd0d14ba7cff1c9a5ff3977b16376..092c2b6386174e8191edcf91fd67a9559eb18391 100644 (file)
@@ -14,7 +14,7 @@ public:
   string getQTypeReport();
 
 private:
-  vector<AtomicCounter> d_qtypecounters;
+  boost::scoped_array<std::atomic<unsigned long>> d_qtypecounters;
   typedef vector<pair<uint16_t, uint64_t> > sizecounters_t;
   sizecounters_t d_sizecounters;
 };
index 71d0f997ec7408e0b6a4afb2bd31fcee2f210bbd..3cfbc13aaabe419ced34b8e924a2a1332ec12989 100644 (file)
@@ -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;
index 01b030f1837f615c548749def76782a2559c6aed..2263ffdb3d8513e32309245d82509902d86f3c88 100644 (file)
@@ -24,7 +24,7 @@ public:
   bool submit(const DNSResourceRecord& rr);
   chunk_t getChunk(bool final=false);
 
-  AtomicCounter d_signed;
+  std::atomic<unsigned long> d_signed;
   int d_queued;
   int d_outstanding;
   unsigned int getReady();
index aeadaae0398eedf97805e518501138325f221778..f3fa17c5f4917a2b0faff700886163f63ccc17c9 100644 (file)
@@ -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);