]> granicus.if.org Git - pdns/commitdiff
work around a boost issue with circular buffer or map of unions, most evident on...
authorbert hubert <bert.hubert@netherlabs.nl>
Fri, 2 Jan 2015 21:40:59 +0000 (22:40 +0100)
committerbert hubert <bert.hubert@netherlabs.nl>
Fri, 2 Jan 2015 21:40:59 +0000 (22:40 +0100)
pdns/iputils.hh
pdns/statbag.cc
pdns/statbag.hh

index c7e0814888b26294dc198df900a2742e162cb3ae..5230443536c4bc01c5e4987214a7ef7d5839ff92 100644 (file)
@@ -80,7 +80,7 @@ union ComboAddress {
       return memcmp(&sin6.sin6_addr.s6_addr, &rhs.sin6.sin6_addr.s6_addr, 16) > 0;
   }
 
-  struct addressOnlyLessThan: public std::binary_function<string, string, bool>
+  struct addressOnlyLessThan: public std::binary_function<ComboAddress, ComboAddress, bool>
   {
     bool operator()(const ComboAddress& a, const ComboAddress& b) const
     {
index 7d352167ea8d4397c88739e15418edae706104e5..188e71b3a7e25e620a42e1950b95e2500f408550 100644 (file)
@@ -229,7 +229,7 @@ void StatBag::declareRing(const string &name, const string &help, unsigned int s
 
 void StatBag::declareComboRing(const string &name, const string &help, unsigned int size)
 {
-  d_comborings[name]=StatRing<ComboAddress, ComboAddress::addressOnlyLessThan >(size);
+  d_comborings[name]=StatRing<SComboAddress>(size);
   d_comborings[name].setHelp(help);
 }
 
@@ -239,11 +239,11 @@ vector<pair<string, unsigned int> > StatBag::getRing(const string &name)
   if(d_rings.count(name))
     return d_rings[name].get();
   else {
-    typedef pair<ComboAddress, unsigned int> stor_t;
+    typedef pair<SComboAddress, unsigned int> stor_t;
     vector<stor_t> raw =d_comborings[name].get();
     vector<pair<string, unsigned int> > ret;
     BOOST_FOREACH(const stor_t& stor, raw) {
-      ret.push_back(make_pair(stor.first.toString(), stor.second));
+      ret.push_back(make_pair(stor.first.ca.toString(), stor.second));
     }
     return ret;
   }
@@ -295,7 +295,7 @@ vector<string>StatBag::listRings()
   vector<string> ret;
   for(map<string,StatRing<string> >::const_iterator i=d_rings.begin();i!=d_rings.end();++i)
     ret.push_back(i->first);
-  for(map<string,StatRing<ComboAddress, ComboAddress::addressOnlyLessThan> >::const_iterator i=d_comborings.begin();i!=d_comborings.end();++i)
+  for(map<string,StatRing<SComboAddress> >::const_iterator i=d_comborings.begin();i!=d_comborings.end();++i)
     ret.push_back(i->first);
 
   return ret;
@@ -307,4 +307,4 @@ bool StatBag::ringExists(const string &name)
 }
 
 template class StatRing<std::string>;
-template class StatRing<ComboAddress, ComboAddress::addressOnlyLessThan >;
+template class StatRing<SComboAddress>;
index a175588a03302e50a6e713ae53d0313d9e002522..ae260f59efffaa6b34be62d1a15b0c2ce6d75086 100644 (file)
 #include "iputils.hh"
 #include <boost/circular_buffer.hpp>
 
+struct SComboAddress
+{
+  SComboAddress(const ComboAddress& orig) : ca(orig) {}
+  ComboAddress ca;
+  bool operator<(const SComboAddress& rhs) const
+  {
+    return ComboAddress::addressOnlyLessThan()(ca, rhs.ca);
+  }
+};
+
+
 template<typename T, typename Comp=std::less<T> >
 class StatRing
 {
@@ -63,7 +74,7 @@ class StatBag
   map<string, AtomicCounter *> d_stats;
   map<string, string> d_keyDescrips;
   map<string,StatRing<string> >d_rings;
-  map<string,StatRing<ComboAddress, ComboAddress::addressOnlyLessThan> >d_comborings;
+  map<string,StatRing<SComboAddress> >d_comborings;
   typedef boost::function<uint64_t(const std::string&)> func_t;
   typedef map<string, func_t> funcstats_t;
   funcstats_t d_funcstats;