Parcourir la source

add empty check for shared_ptr and fix the dead while problem.

zhanglikun il y a 14 ans
Parent
commit
f62f4f06cf
3 fichiers modifiés avec 4 ajouts et 2 suppressions
  1. 1 1
      src/lib/cache/rrset_cache.cc
  2. 2 1
      src/lib/cache/rrset_cache.h
  3. 1 0
      src/lib/cache/rrset_entry.cc

+ 1 - 1
src/lib/cache/rrset_cache.cc

@@ -46,7 +46,7 @@ RRsetCache::lookup(const isc::dns::Name& qname,
            keydata.first, keydata.second, RRClass(class_)));
 
     //If the rrset entry has expired, return NULL.
-    if(time(NULL) > entry_ptr->getExpireTime()) {
+    if(entry_ptr && (time(NULL) > entry_ptr->getExpireTime())) {
         return RRsetEntryPtr();
     }
     return entry_ptr;

+ 2 - 1
src/lib/cache/rrset_cache.h

@@ -79,8 +79,9 @@ private:
     uint16_t class_; // The class of the rrset cache.
     isc::nsas::HashTable<RRsetEntry> rrset_table_;
     isc::nsas::LruList<RRsetEntry> rrset_lru_;
-
 };
+
+typedef boost::shared_ptr<RRsetCache> RRsetCachePtr;
     
 } // namespace cache
 } // namespace isc

+ 1 - 0
src/lib/cache/rrset_entry.cc

@@ -33,6 +33,7 @@ RRsetEntry::RRsetEntry(const isc::dns::RRset& rrset, const RRsetTrustLevel& leve
     rdata_itor->first();
     while(!rdata_itor->isLast()){
         rrset_->addRdata(rdata_itor->getCurrent());
+        rdata_itor->next();
     }
 }