}
}
+void AuthPacketCache::MapCombo::reserve(size_t numberOfEntries)
+{
+#if BOOST_VERSION >= 105600
+ WriteLock wl(&d_mut);
+ d_map.get<HashTag>().reserve(numberOfEntries);
+#endif /* BOOST_VERSION >= 105600 */
+}
+
bool AuthPacketCache::get(DNSPacket& p, DNSPacket& cached)
{
if(!d_ttl) {
void setMaxEntries(uint64_t maxEntries)
{
d_maxEntries = maxEntries;
+ for (auto& shard : d_maps) {
+ shard.reserve(maxEntries / d_maps.size());
+ }
}
void setTTL(uint32_t ttl)
{
MapCombo(const MapCombo&) = delete;
MapCombo& operator=(const MapCombo&) = delete;
+ void reserve(size_t numberOfEntries);
+
pthread_rwlock_t d_mut;
cmap_t d_map;
};
}
}
+void AuthQueryCache::MapCombo::reserve(size_t numberOfEntries)
+{
+#if BOOST_VERSION >= 105600
+ WriteLock wl(&d_mut);
+ d_map.get<HashTag>().reserve(numberOfEntries);
+#endif /* BOOST_VERSION >= 105600 */
+}
+
// called from ueberbackend
bool AuthQueryCache::getEntry(const DNSName &qname, const QType& qtype, vector<DNSZoneRecord>& value, int zoneID)
{
void setMaxEntries(uint64_t maxEntries)
{
d_maxEntries = maxEntries;
+ for (auto& shard : d_maps) {
+ shard.reserve(maxEntries / d_maps.size());
+ }
}
private:
MapCombo(const MapCombo &) = delete;
MapCombo & operator=(const MapCombo &) = delete;
+ void reserve(size_t numberOfEntries);
+
pthread_rwlock_t d_mut;
cmap_t d_map;
};
PC.setTTL(::arg().asNum("cache-ttl"));
PC.setMaxEntries(::arg().asNum("max-packet-cache-entries"));
QC.setMaxEntries(::arg().asNum("max-cache-entries"));
+ DNSSECKeeper::setMaxEntries(::arg().asNum("max-cache-entries"));
if (!PC.enabled() && ::arg().mustDo("log-dns-queries")) {
g_log<<Logger::Warning<<"Packet cache disabled, logging queries without HIT/MISS"<<endl;
pthread_rwlock_t DNSSECKeeper::s_keycachelock = PTHREAD_RWLOCK_INITIALIZER;
AtomicCounter DNSSECKeeper::s_ops;
time_t DNSSECKeeper::s_last_prune;
+size_t DNSSECKeeper::s_maxEntries = 0;
bool DNSSECKeeper::doesDNSSEC()
{
if(now.tv_sec - s_last_prune > (time_t)(30)) {
{
WriteLock l(&s_metacachelock);
- pruneCollection<SequencedTag>(*this, s_metacache, ::arg().asNum("max-cache-entries"));
+ pruneCollection<SequencedTag>(*this, s_metacache, s_maxEntries);
}
{
WriteLock l(&s_keycachelock);
- pruneCollection<SequencedTag>(*this, s_keycache, ::arg().asNum("max-cache-entries"));
+ pruneCollection<SequencedTag>(*this, s_keycache, s_maxEntries);
}
- s_last_prune=time(0);
+ s_last_prune = time(nullptr);
}
}
+
+void DNSSECKeeper::setMaxEntries(size_t maxEntries)
+{
+ s_maxEntries = maxEntries;
+#if BOOST_VERSION >= 105600
+ WriteLock wl(&s_keycachelock);
+ s_keycache.get<KeyCacheTag>().reserve(s_maxEntries);
+#endif /* BOOST_VERSION >= 105600 */
+}
void getSoaEdit(const DNSName& zname, std::string& value);
bool unSecureZone(const DNSName& zone, std::string& error, std::string& info);
bool rectifyZone(const DNSName& zone, std::string& error, std::string& info, bool doTransaction);
+
+ static void setMaxEntries(size_t maxEntries);
+
private:
sequenced<tag<SequencedTag>>
>
> keycache_t;
+
typedef multi_index_container<
METACacheEntry,
indexed_by<
static pthread_rwlock_t s_keycachelock;
static AtomicCounter s_ops;
static time_t s_last_prune;
+ static size_t s_maxEntries;
public:
void preRemoval(const KeyCacheEntry&)