BIND 10 trac493, updated. ca06de9c9e5a017361041a7ce0db4bd37c27e0a7 [trac493] Refactor the code by removing duplicated code, breaking the long line
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu Mar 3 06:33:52 UTC 2011
The branch, trac493 has been updated
via ca06de9c9e5a017361041a7ce0db4bd37c27e0a7 (commit)
via 0e52d28e09894ae1cab993e9cf61a49d00f9be64 (commit)
via f9efa6910cdf152f850a76c039f597f516f0c2ce (commit)
from c0cec0792078fbdd5a6cc5cb19c4361a960d95cf (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 ca06de9c9e5a017361041a7ce0db4bd37c27e0a7
Author: zhanglikun <zhanglikun at cnnic.cn>
Date: Thu Mar 3 14:33:04 2011 +0800
[trac493] Refactor the code by removing duplicated code, breaking the long line
commit 0e52d28e09894ae1cab993e9cf61a49d00f9be64
Merge: f9efa6910cdf152f850a76c039f597f516f0c2ce c0cec0792078fbdd5a6cc5cb19c4361a960d95cf
Author: zhanglikun <zhanglikun at cnnic.cn>
Date: Thu Mar 3 11:59:19 2011 +0800
Merge branch 'trac493' of ssh://bind10.isc.org/var/bind10/git/bind10 into trac493
commit f9efa6910cdf152f850a76c039f597f516f0c2ce
Author: zhanglikun <zhanglikun at cnnic.cn>
Date: Thu Mar 3 11:58:07 2011 +0800
[trac493] Remove blankspace at end of line.
-----------------------------------------------------------------------
Summary of changes:
src/lib/cache/message_entry.cc | 37 +++++++++++--------------
src/lib/cache/message_entry.h | 12 +++++---
src/lib/cache/resolver_cache.cc | 6 +++-
src/lib/cache/resolver_cache.h | 2 +-
src/lib/cache/tests/Makefile.am | 7 +++++
src/lib/cache/tests/message_cache_unittest.cc | 4 +-
6 files changed, 38 insertions(+), 30 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/cache/message_entry.cc b/src/lib/cache/message_entry.cc
index 1c7ebff..ee09f3e 100644
--- a/src/lib/cache/message_entry.cc
+++ b/src/lib/cache/message_entry.cc
@@ -51,7 +51,7 @@ MessageEntry::getRRsetEntries(vector<RRsetEntryPtr>& rrset_entry_vec,
uint16_t entry_count = answer_count_ + authority_count_ + additional_count_;
rrset_entry_vec.reserve(rrset_entry_vec.size() + entry_count);
for (int index = 0; index < entry_count; ++index) {
- boost::shared_ptr<RRsetCache> rrset_cache = rrsets_[index].cache_;
+ boost::shared_ptr<RRsetCache> rrset_cache = rrsets_[index].cache_;
RRsetEntryPtr rrset_entry = rrset_cache->lookup(rrsets_[index].name_,
rrsets_[index].type_);
if (time_now < rrset_entry->getExpireTime()) {
@@ -232,25 +232,24 @@ MessageEntry::parseNegativeResponseAuthoritySection(const isc::dns::Message& msg
uint32_t& min_ttl,
uint16_t& rrset_count)
{
-
// We found the SOA record, so we can cache the message and RRsets in the cache
uint16_t count = 0;
for (RRsetIterator iter = msg.beginSection(Message::SECTION_AUTHORITY);
iter != msg.endSection(Message::SECTION_AUTHORITY);
++iter) {
RRsetPtr rrset_ptr = *iter;
- RRsetTrustLevel level = getRRsetTrustLevel(msg, rrset_ptr, Message::SECTION_AUTHORITY);
- uint32_t rrset_ttl = 0;
- if (rrset_ptr->getType() == RRType::SOA()){
- RRsetEntryPtr rrset_entry = negative_soa_cache_->update(*rrset_ptr, level);
- rrsets_.push_back(RRsetRef(rrset_ptr->getName(), rrset_ptr->getType(), negative_soa_cache_));
- rrset_ttl = rrset_entry->getTTL();
- } else {
- RRsetEntryPtr rrset_entry = rrset_cache_->update(*rrset_ptr, level);
- rrsets_.push_back(RRsetRef(rrset_ptr->getName(), rrset_ptr->getType(), rrset_cache_));
- rrset_ttl = rrset_entry->getTTL();
- }
-
+ RRsetTrustLevel level = getRRsetTrustLevel(msg, rrset_ptr,
+ Message::SECTION_AUTHORITY);
+ boost::shared_ptr<RRsetCache> rrset_cache_ptr = rrset_cache_;
+ if (rrset_ptr->getType() == RRType::SOA()) {
+ rrset_cache_ptr.reset(negative_soa_cache_);
+ }
+
+ RRsetEntryPtr rrset_entry = rrset_cache_ptr->update(*rrset_ptr, level);
+ rrsets_.push_back(RRsetRef(rrset_ptr->getName(),
+ rrset_ptr->getType(),
+ rrset_cache_ptr));
+ uint32_t rrset_ttl = rrset_entry->getTTL();
if (min_ttl > rrset_ttl) {
min_ttl = rrset_ttl;
}
@@ -280,22 +279,18 @@ MessageEntry::initMessageEntry(const isc::dns::Message& msg) {
parseSection(msg, Message::SECTION_AUTHORITY, min_ttl, authority_count_);
parseSection(msg, Message::SECTION_ADDITIONAL, min_ttl, additional_count_);
} else {
- uint16_t rrset_count = 0;
-
- // For negative response, if no soa RRset is found in authority section, dont cache it
+ // For negative response, if no soa RRset is found in authority
+ // section, don't cache it
if (!hasTheRecordInAuthoritySection(msg, RRType::SOA())) {
return;
}
- parseNegativeResponseAuthoritySection(msg, min_ttl, rrset_count);
-
- authority_count_ = rrset_count;
+ parseNegativeResponseAuthoritySection(msg, min_ttl, authority_count_);
parseSection(msg, Message::SECTION_ANSWER, min_ttl, answer_count_);
parseSection(msg, Message::SECTION_ADDITIONAL, min_ttl, additional_count_);
}
expire_time_ = time(NULL) + min_ttl;
-
}
bool
diff --git a/src/lib/cache/message_entry.h b/src/lib/cache/message_entry.h
index 48f81b3..0bef94a 100644
--- a/src/lib/cache/message_entry.h
+++ b/src/lib/cache/message_entry.h
@@ -168,23 +168,27 @@ protected:
//@}
private:
- /// \brief Check whetehr the message is a negative response(NXDOMAIN or NOERROR_NODATA)
+ /// \brief Check whetehr the message is a negative response
+ /// (NXDOMAIN or NOERROR_NODATA)
///
/// \param msg The response message
bool isNegativeResponse(const isc::dns::Message& msg);
- /// \brief Check whether there is some type of record in Authority section
+ /// \brief Check whether there is some type of record in
+ /// Authority section
///
/// \param msg The response message to be checked
/// \param type The RR type that need to check
- bool hasTheRecordInAuthoritySection(const isc::dns::Message& msg, const isc::dns::RRType& type);
+ bool hasTheRecordInAuthoritySection(const isc::dns::Message& msg,
+ const isc::dns::RRType& type);
std::string entry_name_; // The name for this entry(name + type)
HashKey* hash_key_ptr_; // the key for messag entry in hash table.
std::vector<RRsetRef> rrsets_;
boost::shared_ptr<RRsetCache> rrset_cache_; //Normal rrset cache
- boost::shared_ptr<RRsetCache> negative_soa_cache_; // SOA rrset from negative response
+ // SOA rrset from negative response
+ boost::shared_ptr<RRsetCache> negative_soa_cache_;
std::string query_name_; // query name of the message.
uint16_t query_class_; // query class of the message.
diff --git a/src/lib/cache/resolver_cache.cc b/src/lib/cache/resolver_cache.cc
index 34ee043..2e54a93 100644
--- a/src/lib/cache/resolver_cache.cc
+++ b/src/lib/cache/resolver_cache.cc
@@ -35,7 +35,8 @@ ResolverClassCache::ResolverClassCache(const RRClass& cache_class) :
rrsets_cache_ = RRsetCachePtr(new RRsetCache(RRSET_CACHE_DEFAULT_SIZE,
cache_class_.getCode()));
// SOA rrset cache from negative response
- negative_soa_cache_ = RRsetCachePtr(new RRsetCache(NEGATIVE_RRSET_CACHE_DEFAULT_SIZE, cache_class_.getCode()));
+ negative_soa_cache_ = RRsetCachePtr(new RRsetCache(NEGATIVE_RRSET_CACHE_DEFAULT_SIZE,
+ cache_class_.getCode()));
messages_cache_ = MessageCachePtr(new MessageCache(rrsets_cache_,
MESSAGE_CACHE_DEFAULT_SIZE,
@@ -51,7 +52,8 @@ ResolverClassCache::ResolverClassCache(CacheSizeInfo cache_info) :
rrsets_cache_ = RRsetCachePtr(new
RRsetCache(cache_info.rrset_cache_size, klass));
// SOA rrset cache from negative response
- negative_soa_cache_ = RRsetCachePtr(new RRsetCache(cache_info.rrset_cache_size, klass));
+ negative_soa_cache_ = RRsetCachePtr(new RRsetCache(cache_info.rrset_cache_size,
+ klass));
messages_cache_ = MessageCachePtr(new MessageCache(rrsets_cache_,
cache_info.message_cache_size,
diff --git a/src/lib/cache/resolver_cache.h b/src/lib/cache/resolver_cache.h
index b45da16..32214b6 100644
--- a/src/lib/cache/resolver_cache.h
+++ b/src/lib/cache/resolver_cache.h
@@ -47,7 +47,7 @@ public:
/// \param cls The RRClass code
/// \param msg_cache_size The size for the message cache
/// \param rst_cache_size The size for the RRset cache
- CacheSizeInfo(const isc::dns::RRClass& cls,
+ CacheSizeInfo(const isc::dns::RRClass& cls,
uint32_t msg_cache_size,
uint32_t rst_cache_size):
cclass(cls),
diff --git a/src/lib/cache/tests/Makefile.am b/src/lib/cache/tests/Makefile.am
index 9514afc..d80bb1a 100644
--- a/src/lib/cache/tests/Makefile.am
+++ b/src/lib/cache/tests/Makefile.am
@@ -65,3 +65,10 @@ EXTRA_DIST += testdata/message_fromWire3
EXTRA_DIST += testdata/message_fromWire4
EXTRA_DIST += testdata/message_fromWire5
EXTRA_DIST += testdata/message_fromWire6
+EXTRA_DIST += testdata/message_cname_referral.wire
+EXTRA_DIST += testdata/message_example_com_soa.wire
+EXTRA_DIST += testdata/message_nodata_with_soa.wire
+EXTRA_DIST += testdata/message_nxdomain_cname.wire
+EXTRA_DIST += testdata/message_nxdomain_no_soa.wire
+EXTRA_DIST += testdata/message_nxdomain_with_soa.wire
+EXTRA_DIST += testdata/message_referral.wire
diff --git a/src/lib/cache/tests/message_cache_unittest.cc b/src/lib/cache/tests/message_cache_unittest.cc
index 15f29c3..6b9e558 100644
--- a/src/lib/cache/tests/message_cache_unittest.cc
+++ b/src/lib/cache/tests/message_cache_unittest.cc
@@ -53,8 +53,8 @@ public:
uint16_t class_ = RRClass::IN().getCode();
rrset_cache_.reset(new RRsetCache(RRSET_CACHE_DEFAULT_SIZE, class_));
negative_soa_cache_.reset(new RRsetCache(NEGATIVE_RRSET_CACHE_DEFAULT_SIZE, class_));
- message_cache_.reset(new DerivedMessageCache(rrset_cache_,
- MESSAGE_CACHE_DEFAULT_SIZE, class_,
+ message_cache_.reset(new DerivedMessageCache(rrset_cache_,
+ MESSAGE_CACHE_DEFAULT_SIZE, class_,
negative_soa_cache_));
}
More information about the bind10-changes
mailing list