BIND 10 trac497, updated. 2d2093b3eda1d0d09ae852f2dc6feefc4886b71f [trac497] final review comments

BIND 10 source code commits bind10-changes at lists.isc.org
Fri Feb 11 11:21:53 UTC 2011


The branch, trac497 has been updated
       via  2d2093b3eda1d0d09ae852f2dc6feefc4886b71f (commit)
      from  a61a83e551549808ddc80fa99ad453932d001ff0 (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 2d2093b3eda1d0d09ae852f2dc6feefc4886b71f
Author: Jelte Jansen <jelte at isc.org>
Date:   Fri Feb 11 12:20:46 2011 +0100

    [trac497] final review comments
    
    as to copySection, it's now called appendSection, and works the other
    way around (i.e. it copies from a source message into the object,
    instead of copying from the object to a target message), which feels
    more natural

-----------------------------------------------------------------------

Summary of changes:
 src/lib/asiolink/asiolink.cc          |    6 +++---
 src/lib/dns/message.cc                |   17 +++++++++--------
 src/lib/dns/message.h                 |   10 +++++-----
 src/lib/dns/tests/message_unittest.cc |   22 +++++++++++-----------
 src/lib/resolve/resolve.cc            |    6 +++---
 5 files changed, 31 insertions(+), 30 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/asiolink/asiolink.cc b/src/lib/asiolink/asiolink.cc
index a84af4c..62f94c9 100644
--- a/src/lib/asiolink/asiolink.cc
+++ b/src/lib/asiolink/asiolink.cc
@@ -440,8 +440,8 @@ private:
                 return true;
             }
 
-            incoming.copySection(*answer_message_,
-                Message::SECTION_ANSWER);
+            answer_message_->appendSection(Message::SECTION_ANSWER,
+                                           incoming);
             setZoneServersToRoot();
 
             question_ = Question(cname_target, question_.getClass(),
@@ -574,7 +574,7 @@ public:
                 boost::lexical_cast<string>(upstream_root_->size()) + 
                 "\n");
             for(AddressVector::iterator it = upstream_root_->begin();
-                it < upstream_root_->end(); it++) {
+                it < upstream_root_->end(); ++it) {
             zone_servers_.push_back(addr_t(it->first,it->second));
             dlog("Put " + zone_servers_.back().first + "into root list\n");
             }
diff --git a/src/lib/dns/message.cc b/src/lib/dns/message.cc
index 752df5a..c966116 100644
--- a/src/lib/dns/message.cc
+++ b/src/lib/dns/message.cc
@@ -777,21 +777,22 @@ Message::clear(Mode mode) {
 }
 
 void
-Message::copySection(Message& target, const Section section) const {
+Message::appendSection(const Section section, const Message& source) {
     if (section >= MessageImpl::NUM_SECTIONS) {
         isc_throw(OutOfRange, "Invalid message section: " << section);
     }
 
     if (section == SECTION_QUESTION) {
-        BOOST_FOREACH(QuestionPtr q, impl_->questions_) {
-            std::cout << "[XX] copy question " << q << std::endl;
-            target.addQuestion(q);
+        for (QuestionIterator qi = source.beginQuestion();
+             qi != source.endQuestion();
+             ++qi) {
+            addQuestion(*qi);
         }
     } else {
-        std::cout << "[XX] copy section " << section << std::endl;
-        BOOST_FOREACH(RRsetPtr r, impl_->rrsets_[section]) {
-            std::cout << "[XX] copy rrset " << r << std::endl;
-            target.addRRset(section, r, false);
+        for (RRsetIterator rrsi = source.beginSection(section);
+             rrsi != source.endSection(section);
+             ++rrsi) {
+            addRRset(section, *rrsi);
         }
     }
 }
diff --git a/src/lib/dns/message.h b/src/lib/dns/message.h
index fb7a8e6..11167d2 100644
--- a/src/lib/dns/message.h
+++ b/src/lib/dns/message.h
@@ -498,12 +498,12 @@ public:
     /// specified mode.
     void clear(Mode mode);
 
-    /// \brief Adds all rrsets in the given section to the same section
-    /// in target
+    /// \brief Adds all rrsets from the source the given section in the
+    /// source message to the same section of this message
     ///
-    /// \param target The target Message
-    /// \param section the section to copy
-    void copySection(Message& target, const Section section) const;
+    /// \param section the section to append
+    /// \param target The source Message
+    void appendSection(const Section section, const Message& source);
 
     /// \brief Prepare for making a response from a request.
     ///
diff --git a/src/lib/dns/tests/message_unittest.cc b/src/lib/dns/tests/message_unittest.cc
index 5b08290..92adbc9 100644
--- a/src/lib/dns/tests/message_unittest.cc
+++ b/src/lib/dns/tests/message_unittest.cc
@@ -380,21 +380,21 @@ TEST_F(MessageTest, badEndSection) {
     EXPECT_THROW(message_render.endSection(bogus_section), OutOfRange);
 }
 
-TEST_F(MessageTest, copySection) {
+TEST_F(MessageTest, appendSection) {
     Message target(Message::RENDER);
 
     // Section check
-    EXPECT_THROW(message_render.copySection(target, bogus_section),
+    EXPECT_THROW(target.appendSection(bogus_section, message_render),
                  OutOfRange);
 
     // Make sure nothing is copied if there is nothing to copy
-    message_render.copySection(target, Message::SECTION_QUESTION);
+    target.appendSection(Message::SECTION_QUESTION, message_render);
     EXPECT_EQ(0, target.getRRCount(Message::SECTION_QUESTION));
-    message_render.copySection(target, Message::SECTION_ANSWER);
+    target.appendSection(Message::SECTION_ANSWER, message_render);
     EXPECT_EQ(0, target.getRRCount(Message::SECTION_ANSWER));
-    message_render.copySection(target, Message::SECTION_AUTHORITY);
+    target.appendSection(Message::SECTION_AUTHORITY, message_render);
     EXPECT_EQ(0, target.getRRCount(Message::SECTION_AUTHORITY));
-    message_render.copySection(target, Message::SECTION_ADDITIONAL);
+    target.appendSection(Message::SECTION_ADDITIONAL, message_render);
     EXPECT_EQ(0, target.getRRCount(Message::SECTION_ADDITIONAL));
 
     // Now add some data, copy again, and see if it got added
@@ -405,20 +405,20 @@ TEST_F(MessageTest, copySection) {
     message_render.addRRset(Message::SECTION_ADDITIONAL, rrset_a);
     message_render.addRRset(Message::SECTION_ADDITIONAL, rrset_aaaa);
 
-    message_render.copySection(target, Message::SECTION_QUESTION);
+    target.appendSection(Message::SECTION_QUESTION, message_render);
     EXPECT_EQ(1, target.getRRCount(Message::SECTION_QUESTION));
 
-    message_render.copySection(target, Message::SECTION_ANSWER);
+    target.appendSection(Message::SECTION_ANSWER, message_render);
     EXPECT_EQ(2, target.getRRCount(Message::SECTION_ANSWER));
     EXPECT_TRUE(target.hasRRset(Message::SECTION_ANSWER, test_name,
         RRClass::IN(), RRType::A()));
 
-    message_render.copySection(target, Message::SECTION_AUTHORITY);
+    target.appendSection(Message::SECTION_AUTHORITY, message_render);
     EXPECT_EQ(2, target.getRRCount(Message::SECTION_AUTHORITY));
     EXPECT_TRUE(target.hasRRset(Message::SECTION_AUTHORITY, test_name,
         RRClass::IN(), RRType::A()));
 
-    message_render.copySection(target, Message::SECTION_ADDITIONAL);
+    target.appendSection(Message::SECTION_ADDITIONAL, message_render);
     EXPECT_EQ(3, target.getRRCount(Message::SECTION_ADDITIONAL));
     EXPECT_TRUE(target.hasRRset(Message::SECTION_ADDITIONAL, test_name,
         RRClass::IN(), RRType::A()));
@@ -428,7 +428,7 @@ TEST_F(MessageTest, copySection) {
     // One more test, test to see if the section gets added, not replaced
     Message source2(Message::RENDER);
     source2.addRRset(Message::SECTION_ANSWER, rrset_aaaa);
-    source2.copySection(target, Message::SECTION_ANSWER);
+    target.appendSection(Message::SECTION_ANSWER, source2);
     EXPECT_EQ(3, target.getRRCount(Message::SECTION_ANSWER));
     EXPECT_TRUE(target.hasRRset(Message::SECTION_ANSWER, test_name,
         RRClass::IN(), RRType::A()));
diff --git a/src/lib/resolve/resolve.cc b/src/lib/resolve/resolve.cc
index d581ca2..a0c44de 100644
--- a/src/lib/resolve/resolve.cc
+++ b/src/lib/resolve/resolve.cc
@@ -47,9 +47,9 @@ makeErrorMessage(MessagePtr answer_message,
 void copyResponseMessage(const Message& source, MessagePtr target) {
     target->setRcode(source.getRcode());
 
-    source.copySection(*target, Message::SECTION_ANSWER);
-    source.copySection(*target, Message::SECTION_AUTHORITY);
-    source.copySection(*target, Message::SECTION_ADDITIONAL);
+    target->appendSection(Message::SECTION_ANSWER, source);
+    target->appendSection(Message::SECTION_AUTHORITY, source);
+    target->appendSection(Message::SECTION_ADDITIONAL, source);
 }
 
 




More information about the bind10-changes mailing list