Browse Source

[master] Fix the minor problem brought on by merging trac493: the blank space in changelog and EOL, add the unmerged test case of message cache.

zhanglikun 14 years ago
parent
commit
728f0af269

+ 3 - 3
ChangeLog

@@ -1,7 +1,7 @@
   199.  [func]           ocean
-        Cache negative responses (NXDOMAIN/NODATA) from authoritative
-        server for recursive resolver.
-        (Trac #493, git f8fb852bc6aef292555063590c361f01cf29e5ca)
+	Cache negative responses (NXDOMAIN/NODATA) from authoritative
+	server for recursive resolver.
+	(Trac #493, git f8fb852bc6aef292555063590c361f01cf29e5ca)
 
   198.	[bug]		jinmei
 	b10-auth, src/lib/datasrc: fixed a bug where hot spot cache failed

+ 1 - 1
src/lib/cache/message_entry.h

@@ -69,7 +69,7 @@ public:
     ///        since some new rrset entries may be inserted into
     ///        rrset cache, or the existed rrset entries need
     ///        to be updated.
-    /// \param negative_soa_cache the pointer of RRsetCAche. This
+    /// \param negative_soa_cache the pointer of RRsetCache. This
     ///        cache is used only for storing SOA rrset from negative
     ///        response (NXDOMAIN or NOERROR_NODATA)
     MessageEntry(const isc::dns::Message& message,

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

@@ -50,7 +50,7 @@ isNegativeResponse(const isc::dns::Message& msg) {
     } else if (msg.getRcode() == Rcode::NOERROR()) {
         // no data in the answer section
         if (msg.getRRCount(Message::SECTION_ANSWER) == 0) {
-            // NODATA type 1/ type 2 (ref sec2.2 of RFC2308) 
+            // NODATA type 1/ type 2 (ref sec2.2 of RFC2308)
             if (hasTheRecordInAuthoritySection(msg, RRType::SOA())) {
                 return (true);
             } else if (!hasTheRecordInAuthoritySection(msg, RRType::NS())) {

+ 1 - 1
src/lib/cache/message_utility.h

@@ -25,7 +25,7 @@ namespace cache {
 /// \brief Some utility functions to extract info from message
 ///
 /// We need to check the message before cache it, for example, if no SOA
-/// record is found in the Authority section of NXDOMAIN response, the 
+/// record is found in the Authority section of NXDOMAIN response, the
 /// message cannot be cached
 namespace MessageUtility{
 

+ 3 - 3
src/lib/cache/resolver_cache.h

@@ -135,8 +135,8 @@ public:
     ///       the right class
     /// TODO: Share the NXDOMAIN info between different type queries
     ///       current implementation can only cache for the type that
-    ///       user quired, for example, if user query A record of 
-    ///       a.example. and the server replied with NXDOMAIN, this 
+    ///       user quired, for example, if user query A record of
+    ///       a.example. and the server replied with NXDOMAIN, this
     ///       should be cached for all the types queries of a.example.
     bool update(const isc::dns::Message& msg);
 
@@ -161,7 +161,7 @@ public:
     ///
     /// \return The RRClass of this cache
     const isc::dns::RRClass& getClass() const;
-    
+
 private:
     /// \brief Update rrset cache.
     ///

+ 7 - 2
src/lib/cache/tests/message_cache_unittest.cc

@@ -70,7 +70,7 @@ public:
                         message_render(Message::RENDER)
     {
         uint16_t class_ = RRClass::IN().getCode();
-        rrset_cache_.reset(new RRsetCache(RRSET_CACHE_DEFAULT_SIZE, class_));
+        rrset_cache_.reset(new DerivedRRsetCache(RRSET_CACHE_DEFAULT_SIZE, class_));
         negative_soa_cache_.reset(new RRsetCache(NEGATIVE_RRSET_CACHE_DEFAULT_SIZE, class_));
         // Set the message cache size to 1, make it easy for unittest.
         message_cache_.reset(new DerivedMessageCache(rrset_cache_, 1, class_,
@@ -79,7 +79,7 @@ public:
 
 protected:
     boost::shared_ptr<DerivedMessageCache> message_cache_;
-    RRsetCachePtr rrset_cache_;
+    boost::shared_ptr<DerivedRRsetCache> rrset_cache_;
     RRsetCachePtr negative_soa_cache_;
     Message message_parse;
     Message message_render;
@@ -110,6 +110,11 @@ TEST_F(MessageCacheTest, testLookup) {
     Name qname1("test.example.net.");
     EXPECT_TRUE(message_cache_->lookup(qname1, RRType::A(), message_render));
 
+    // Test looking up message which has expired rrset or some rrset
+    // has been removed from the rrset cache.
+    rrset_cache_->removeRRsetEntry(qname1, RRType::A());
+    EXPECT_FALSE(message_cache_->lookup(qname1, RRType::A(), message_render));
+
     // Update one message entry which has expired to message cache.
     updateMessageCache("message_fromWire9", message_cache_);
     EXPECT_EQ(message_cache_->messages_count(), 3);