BIND 10 master, updated. aba4c4067da0dc63c97c6356dc3137651755ffce Merge branch 'master' into trac643
BIND 10 source code commits
bind10-changes at lists.isc.org
Tue Mar 15 11:47:48 UTC 2011
The branch, master has been updated
via aba4c4067da0dc63c97c6356dc3137651755ffce (commit)
via 963acb307871f945870c61699cffee72de1c7b65 (commit)
via 3692ad59eab42084765ef68acea3eb24a9e327b1 (commit)
via 050c451f53da820f9b5ef47dcc469261a595d014 (commit)
via dd4e05070a8868a7f42eab9096f0b4d506bbc027 (commit)
via acbd9518519498fcf9d476b5417bcbbb2b9141be (commit)
from e79153fe56e7d514bd2ddf70450058e863c72d51 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit aba4c4067da0dc63c97c6356dc3137651755ffce
Merge: 963acb307871f945870c61699cffee72de1c7b65 e79153fe56e7d514bd2ddf70450058e863c72d51
Author: zhanglikun <zhanglikun at cnnic.cn>
Date: Tue Mar 15 19:46:45 2011 +0800
Merge branch 'master' into trac643
commit 963acb307871f945870c61699cffee72de1c7b65
Author: zhanglikun <zhanglikun at cnnic.cn>
Date: Tue Mar 15 19:42:52 2011 +0800
[trac643] Fix comments problem according jelte's review result.
commit 3692ad59eab42084765ef68acea3eb24a9e327b1
Merge: 050c451f53da820f9b5ef47dcc469261a595d014 dd4e05070a8868a7f42eab9096f0b4d506bbc027
Author: zhanglikun <zhanglikun at cnnic.cn>
Date: Tue Mar 15 19:40:30 2011 +0800
Merge branch 'trac643' of ssh://bind10.isc.org/var/bind10/git/bind10 into trac643
commit 050c451f53da820f9b5ef47dcc469261a595d014
Author: zhanglikun <zhanglikun at cnnic.cn>
Date: Fri Mar 11 19:45:55 2011 +0800
[trac643] Add clear() function to lru list, which is used to clear all the elements of list.
commit dd4e05070a8868a7f42eab9096f0b4d506bbc027
Author: zhanglikun <zhanglikun at cnnic.cn>
Date: Fri Mar 11 19:45:55 2011 +0800
Add clear() function to lru list, which is used to clear all the elements of list.
commit acbd9518519498fcf9d476b5417bcbbb2b9141be
Author: Jelte Jansen <jelte at isc.org>
Date: Thu Mar 10 17:15:45 2011 +0100
[trac643] fix memory leak in MessageEntry
-----------------------------------------------------------------------
Summary of changes:
src/lib/cache/message_cache.cc | 5 +++++
src/lib/cache/message_cache.h | 2 +-
src/lib/cache/message_entry.h | 2 ++
src/lib/cache/rrset_cache.h | 6 ++++--
src/lib/nsas/lru_list.h | 26 ++++++++++++++++++++++++++
src/lib/nsas/tests/lru_list_unittest.cc | 29 +++++++++++++++++++++++++++++
6 files changed, 67 insertions(+), 3 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/cache/message_cache.cc b/src/lib/cache/message_cache.cc
index 50922fd..0464f87 100644
--- a/src/lib/cache/message_cache.cc
+++ b/src/lib/cache/message_cache.cc
@@ -41,6 +41,11 @@ MessageCache::MessageCache(const RRsetCachePtr& rrset_cache,
{
}
+MessageCache::~MessageCache() {
+ // Destroy all the message entries in the cache.
+ message_lru_.clear();
+}
+
bool
MessageCache::lookup(const isc::dns::Name& qname,
const isc::dns::RRType& qtype,
diff --git a/src/lib/cache/message_cache.h b/src/lib/cache/message_cache.h
index 63db681..790ed83 100644
--- a/src/lib/cache/message_cache.h
+++ b/src/lib/cache/message_cache.h
@@ -47,7 +47,7 @@ public:
const RRsetCachePtr& negative_soa_cache);
/// \brief Destructor function
- virtual ~MessageCache() {}
+ virtual ~MessageCache();
/// \brief Look up message in cache.
/// \param message generated response message if the message entry
diff --git a/src/lib/cache/message_entry.h b/src/lib/cache/message_entry.h
index 7d86495..6775ff6 100644
--- a/src/lib/cache/message_entry.h
+++ b/src/lib/cache/message_entry.h
@@ -76,6 +76,8 @@ public:
const RRsetCachePtr& rrset_cache,
const RRsetCachePtr& negative_soa_cache);
+ ~MessageEntry() { delete hash_key_ptr_; };
+
/// \brief generate one dns message according
/// the rrsets information of the message.
///
diff --git a/src/lib/cache/rrset_cache.h b/src/lib/cache/rrset_cache.h
index 5bf2730..104c2a5 100644
--- a/src/lib/cache/rrset_cache.h
+++ b/src/lib/cache/rrset_cache.h
@@ -40,12 +40,14 @@ private:
RRsetCache(const RRsetCache&);
RRsetCache& operator=(const RRsetCache&);
public:
- /// \brief Constructor
+ /// \brief Constructor and Destructor
///
/// \param cache_size the size of rrset cache.
/// \param rrset_class the class of rrset cache.
RRsetCache(uint32_t cache_size, uint16_t rrset_class);
- virtual ~RRsetCache() {}
+ virtual ~RRsetCache() {
+ rrset_lru_.clear(); // Clear the rrset entries in the list.
+ }
//@}
/// \brief Look up rrset in cache.
diff --git a/src/lib/nsas/lru_list.h b/src/lib/nsas/lru_list.h
index b7bd386..b057baf 100644
--- a/src/lib/nsas/lru_list.h
+++ b/src/lib/nsas/lru_list.h
@@ -109,6 +109,13 @@ public:
/// \param element Reference to the element to touch.
virtual void touch(boost::shared_ptr<T>& element);
+ /// \brief Drop All the Elements in the List .
+ ///
+ /// All the elements will be dropped from the list container, and their
+ /// drop handler(if there is one) will be called, when done, the size of
+ /// of list will be 0.
+ virtual void clear();
+
/// \brief Return Size of the List
///
/// An independent count is kept of the list size, as list.size() may take
@@ -228,6 +235,25 @@ void LruList<T>::touch(boost::shared_ptr<T>& element) {
}
}
+// Clear the list- when done, the size of list will be 0.
+template <typename T>
+void LruList<T>::clear() {
+ // Protect list against concurrent access
+ isc::locks::scoped_lock<isc::locks::mutex> lock(mutex_);
+
+ // ... and update the count while we have the mutex.
+ count_ = 0;
+ typename std::list<boost::shared_ptr<T> >::iterator iter;
+ if (dropped_) {
+ for (iter = lru_.begin(); iter != lru_.end(); ++iter) {
+ // Call the drop handler.
+ (*dropped_)(iter->get());
+ }
+ }
+
+ lru_.clear();
+}
+
} // namespace nsas
} // namespace isc
diff --git a/src/lib/nsas/tests/lru_list_unittest.cc b/src/lib/nsas/tests/lru_list_unittest.cc
index 0161f2b..e286826 100644
--- a/src/lib/nsas/tests/lru_list_unittest.cc
+++ b/src/lib/nsas/tests/lru_list_unittest.cc
@@ -251,6 +251,35 @@ TEST_F(LruListTest, Dropped) {
EXPECT_EQ(0, (entry3_->getClass().getCode() & 0x8000));
}
+// Clear functor tests: tests whether all the elements in
+// the list are dropped properly and the size of list is
+// set to 0.
+TEST_F(LruListTest, Clear) {
+ // Create an object with an expiration handler.
+ LruList<TestEntry> lru(3, new Dropped());
+
+ // Fill the list
+ lru.add(entry1_);
+ lru.add(entry2_);
+ lru.add(entry3_);
+
+ EXPECT_EQ(RRClass::IN(), entry1_->getClass());
+ EXPECT_EQ(RRClass::CH(), entry2_->getClass());
+ EXPECT_EQ(RRClass::HS(), entry3_->getClass());
+
+ EXPECT_EQ(0, (entry1_->getClass().getCode() & 0x8000));
+ EXPECT_EQ(0, (entry2_->getClass().getCode() & 0x8000));
+ EXPECT_EQ(0, (entry3_->getClass().getCode() & 0x8000));
+
+ // Clear the lru list, and check the drop handler run
+ lru.clear();
+ EXPECT_NE(0, (entry1_->getClass().getCode() & 0x8000));
+ EXPECT_NE(0, (entry2_->getClass().getCode() & 0x8000));
+ EXPECT_NE(0, (entry3_->getClass().getCode() & 0x8000));
+
+ EXPECT_EQ(0, lru.size());
+}
+
// Miscellaneous tests - pathological conditions
TEST_F(LruListTest, Miscellaneous) {
More information about the bind10-changes
mailing list