}
for (auto& content : maps) {
- auto mc = content.d_content.lock();
+ auto mc = content.lock();
mc->invalidate();
auto& sidx = boost::multi_index::get<S>(mc->d_map);
uint64_t erased = 0, lookedAt = 0;
while (true) {
size_t pershard = toTrim / maps_size + 1;
for (auto& content : maps) {
- auto mc = content.d_content.lock();
+ auto mc = content.lock();
mc->invalidate();
auto& sidx = boost::multi_index::get<S>(mc->d_map);
size_t removed = 0;
{
uint64_t c = 0, a = 0;
for (auto& mc : d_maps) {
- auto content = mc.d_content.lock();
+ auto content = mc.lock();
c += content->d_contended_count;
a += content->d_acquired_count;
}
// XXX!
size_t count = 0;
for (auto& mc : d_maps) {
- auto content = mc.d_content.lock();
+ auto content = mc.lock();
count += content->d_ecsIndex.size();
}
return count;
{
size_t ret = 0;
for (auto& mc : d_maps) {
- auto m = mc.d_content.lock();
+ auto m = mc.lock();
for (const auto& i : m->d_map) {
ret += sizeof(struct CacheEntry);
ret += i.d_qname.toString().length();
}
auto& mc = getMap(qname);
- auto map = mc.d_content.lock();
+ auto map = mc.lock();
/* If we don't have any netmask-specific entries at all, let's just skip this
to be able to use the nice d_cachecache hack. */
void MemRecursorCache::replace(time_t now, const DNSName &qname, const QType qt, const vector<DNSRecord>& content, const vector<shared_ptr<RRSIGRecordContent>>& signatures, const std::vector<std::shared_ptr<DNSRecord>>& authorityRecs, bool auth, const DNSName& authZone, boost::optional<Netmask> ednsmask, const OptTag& routingTag, vState state, boost::optional<ComboAddress> from)
{
auto& mc = getMap(qname);
- auto map = mc.d_content.lock();
+ auto map = mc.lock();
map->d_cachecachevalid = false;
if (ednsmask) {
if (!sub) {
auto& mc = getMap(name);
- auto map = mc.d_content.lock();
+ auto map = mc.lock();
map->d_cachecachevalid = false;
auto& idx = map->d_map.get<OrderedTag>();
auto range = idx.equal_range(name);
}
else {
for (auto& mc : d_maps) {
- auto map = mc.d_content.lock();
+ auto map = mc.lock();
map->d_cachecachevalid = false;
auto& idx = map->d_map.get<OrderedTag>();
for (auto i = idx.lower_bound(name); i != idx.end(); ) {
bool MemRecursorCache::doAgeCache(time_t now, const DNSName& name, const QType qtype, uint32_t newTTL)
{
auto& mc = getMap(name);
- auto map = mc.d_content.lock();
+ auto map = mc.lock();
cache_t::iterator iter = map->d_map.find(tie(name, qtype));
if (iter == map->d_map.end()) {
return false;
}
auto& mc = getMap(qname);
- auto map = mc.d_content.lock();
+ auto map = mc.lock();
bool updated = false;
if (!map->d_ecsIndex.empty() && !routingTag) {
uint64_t count = 0;
for (auto& mc : d_maps) {
- auto map = mc.d_content.lock();
+ auto map = mc.lock();
const auto& sidx = map->d_map.get<SequencedTag>();
time_t now = time(nullptr);
}
};
- LockGuarded<LockedContent> d_content;
std::atomic<uint64_t> d_entriesCount{0};
LockGuardedTryHolder<LockedContent> lock()
++locked->d_acquired_count;
return locked;
}
+
+ private:
+ LockGuarded<LockedContent> d_content;
};
vector<MapCombo> d_maps;
DNSName lastLabel = qname.getLastLabel();
auto& map = getMap(lastLabel);
- auto content = map.d_content.lock();
+ auto content = map.lock();
negcache_t::const_iterator ni = content->d_map.find(tie(lastLabel, qtnull));
bool NegCache::get(const DNSName& qname, const QType& qtype, const struct timeval& now, NegCacheEntry& ne, bool typeMustMatch)
{
auto& map = getMap(qname);
- auto content = map.d_content.lock();
+ auto content = map.lock();
const auto& idx = content->d_map.get<NegCacheEntry>();
auto range = idx.equal_range(qname);
{
bool inserted = false;
auto& map = getMap(ne.d_name);
- auto content = map.d_content.lock();
+ auto content = map.lock();
inserted = lruReplacingInsert<SequenceTag>(content->d_map, ne);
if (inserted) {
++map.d_entriesCount;
void NegCache::updateValidationStatus(const DNSName& qname, const QType& qtype, const vState newState, boost::optional<time_t> capTTD)
{
auto& mc = getMap(qname);
- auto map = mc.d_content.lock();
+ auto map = mc.lock();
auto range = map->d_map.equal_range(tie(qname, qtype));
if (range.first != range.second) {
size_t NegCache::count(const DNSName& qname)
{
auto& map = getMap(qname);
- auto content = map.d_content.lock();
+ auto content = map.lock();
return content->d_map.count(tie(qname));
}
size_t NegCache::count(const DNSName& qname, const QType qtype)
{
auto& map = getMap(qname);
- auto content = map.d_content.lock();
+ auto content = map.lock();
return content->d_map.count(tie(qname, qtype));
}
size_t ret = 0;
if (subtree) {
for (auto& map : d_maps) {
- auto m = map.d_content.lock();
+ auto m = map.lock();
for (auto i = m->d_map.lower_bound(tie(name)); i != m->d_map.end();) {
if (!i->d_name.isPartOf(name))
break;
}
auto& map = getMap(name);
- auto content = map.d_content.lock();
+ auto content = map.lock();
auto range = content->d_map.equal_range(tie(name));
auto i = range.first;
while (i != range.second) {
void NegCache::clear()
{
for (auto& map : d_maps) {
- auto m = map.d_content.lock();
+ auto m = map.lock();
m->d_map.clear();
map.d_entriesCount = 0;
}
size_t ret = 0;
for (auto& mc : d_maps) {
- auto m = mc.d_content.lock();
+ auto m = mc.lock();
auto& sidx = m->d_map.get<SequenceTag>();
for (const NegCacheEntry& ne : sidx) {
ret++;
uint64_t d_acquired_count{0};
void invalidate() {}
};
- LockGuarded<LockedContent> d_content;
std::atomic<uint64_t> d_entriesCount{0};
LockGuardedTryHolder<MapCombo::LockedContent> lock()
++locked->d_acquired_count;
return locked;
}
+
+ private:
+
+ LockGuarded<LockedContent> d_content;
};
vector<MapCombo> d_maps;