From: bert hubert Date: Mon, 26 Sep 2016 10:12:59 +0000 (+0200) Subject: make sure we clean based on sequence index and not on hash index. This bug potentiall... X-Git-Tag: dnsdist-1.1.0-beta2~108^2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6e732e213f5f2ad93b8f77929c5b8ed6fad0a7c6;p=pdns make sure we clean based on sequence index and not on hash index. This bug potentially repeats for all users of PruneCollection. --- diff --git a/pdns/packetcache.cc b/pdns/packetcache.cc index 29de64819..498c92a53 100644 --- a/pdns/packetcache.cc +++ b/pdns/packetcache.cc @@ -416,10 +416,9 @@ void PacketCache::cleanup() unsigned int totErased=0; for(auto& mc : d_maps) { WriteLock wl(&mc.d_mut); - typedef cmap_t::nth_index<1>::type sequence_t; - sequence_t& sidx=mc.d_map.get<1>(); + auto& sidx = boost::multi_index::get(mc.d_map); unsigned int erased=0, lookedAt=0; - for(sequence_t::iterator i=sidx.begin(); i != sidx.end(); lookedAt++) { + for(auto i=sidx.begin(); i != sidx.end(); lookedAt++) { if(i->ttd < now) { sidx.erase(i++); erased++; diff --git a/pdns/packetcache.hh b/pdns/packetcache.hh index 22e455a48..dd23524cb 100644 --- a/pdns/packetcache.hh +++ b/pdns/packetcache.hh @@ -113,6 +113,7 @@ private: void getTTLS(); struct UnorderedNameTag{}; + struct SequenceTag{}; typedef multi_index_container< CacheEntry, indexed_by < @@ -136,7 +137,7 @@ private: member, member, member > > , - sequenced<> + sequenced> > > cmap_t;