Commit 5b825a61 authored by zhanglikun's avatar zhanglikun
Browse files

[trac661] Remove expired rrset entry when looking up

parent 5ecd1322
......@@ -145,6 +145,11 @@ protected:
bool getRRsetEntries(std::vector<RRsetEntryPtr>& rrset_entry_vec,
const time_t time_now);
/// \brief Get
time_t getExpireTime() const {
return (expire_time_);
}
time_t expire_time_; // Expiration time of the message.
//@}
......
......@@ -42,10 +42,17 @@ RRsetCache::lookup(const isc::dns::Name& qname,
{
const string entry_name = genCacheEntryName(qname, qtype);
RRsetEntryPtr entry_ptr = rrset_table_.get(HashKey(entry_name, RRClass(class_)));
if (entry_ptr && entry_ptr->getExpireTime() > time(NULL)) {
// Only touch the non-expired rrset entries
rrset_lru_.touch(entry_ptr);
return (entry_ptr);
if (entry_ptr) {
if (entry_ptr->getExpireTime() > time(NULL)) {
// Only touch the non-expired rrset entries
rrset_lru_.touch(entry_ptr);
return (entry_ptr);
} else {
// the rrset entry has expired, so just remove it from
// hash table and lru list.
rrset_table_.remove(entry_ptr->hashKey());
rrset_lru_.remove(entry_ptr);
}
}
return (RRsetEntryPtr());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment