BIND 10 trac598, updated. 617ec7cf8793d84e92b63aca279768a7bf0164cf [trac598] step 1; make fetchdata keep (a pointer to) a full query message

BIND 10 source code commits bind10-changes at lists.isc.org
Mon Mar 14 13:54:39 UTC 2011


The branch, trac598 has been updated
       via  617ec7cf8793d84e92b63aca279768a7bf0164cf (commit)
      from  f6556f773732939bf68129e8c1fa10e84f8f2e36 (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 617ec7cf8793d84e92b63aca279768a7bf0164cf
Author: Jelte Jansen <jelte at isc.org>
Date:   Thu Mar 10 15:34:30 2011 +0100

    [trac598] step 1; make fetchdata keep (a pointer to) a full query message
    
    instead of a question only

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

Summary of changes:
 src/lib/asiolink/io_fetch.cc |   28 +++++++++++++++-------------
 src/lib/asiolink/io_fetch.h  |   11 ++++-------
 2 files changed, 19 insertions(+), 20 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/asiolink/io_fetch.cc b/src/lib/asiolink/io_fetch.cc
index 04993f4..6cd6064 100644
--- a/src/lib/asiolink/io_fetch.cc
+++ b/src/lib/asiolink/io_fetch.cc
@@ -64,10 +64,18 @@ namespace asiolink {
 IOFetch::IOFetch(int protocol, IOService& service,
     const isc::dns::Question& question, const IOAddress& address, uint16_t port,
     isc::dns::OutputBufferPtr& buff, Callback* cb, int wait)
-    :
-    data_(new IOFetch::IOFetchData(protocol, service, question, address,
-        port, buff, cb, wait))
 {
+    MessagePtr query_msg(new Message(Message::RENDER));
+    
+    query_msg->setQid(QidGenerator::getInstance().generateQid());
+    query_msg->setOpcode(Opcode::QUERY());
+    query_msg->setRcode(Rcode::NOERROR());
+    query_msg->setHeaderFlag(Message::HEADERFLAG_RD);
+    query_msg->addQuestion(question);
+
+    data_ = boost::shared_ptr<IOFetchData>(new IOFetch::IOFetchData(
+        protocol, service, query_msg, address,
+        port, buff, cb, wait));
 }
 
 /// The function operator is implemented with the "stackless coroutine"
@@ -85,20 +93,13 @@ IOFetch::operator()(error_code ec, size_t length) {
         /// This is done in a different scope to allow inline variable
         /// declarations.
         {
-            Message msg(Message::RENDER);
-            
-            msg.setQid(data_->qid);
-            msg.setOpcode(Opcode::QUERY());
-            msg.setRcode(Rcode::NOERROR());
-            msg.setHeaderFlag(Message::HEADERFLAG_RD);
-            msg.addQuestion(data_->question);
             MessageRenderer renderer(*data_->msgbuf);
-            msg.toWire(renderer);
+            data_->query_message->toWire(renderer);
 
             // As this is a new fetch, clear the amount of data received
             data_->cumulative = 0;
 
-            dlog("Sending " + msg.toText() + " to " +
+            dlog("Sending " + data_->query_message->toText() + " to " +
                 data_->remote->getAddress().toText());
         }
 
@@ -146,7 +147,8 @@ IOFetch::operator()(error_code ec, size_t length) {
             // read code)
             // This is just a quick way to check it, if we get the right ID
             // (TODO: from the right address), break the receive-loop
-            if (readUint16(data_->data.get(), length) == data_->qid) {
+            if (readUint16(data_->data.get(), length) ==
+                data_->query_message->getQid()) {
                 break;
             }  else {
                 dlog("Wrong QID in response, waiting for next one");
diff --git a/src/lib/asiolink/io_fetch.h b/src/lib/asiolink/io_fetch.h
index a64fc22..d0bad34 100644
--- a/src/lib/asiolink/io_fetch.h
+++ b/src/lib/asiolink/io_fetch.h
@@ -119,7 +119,7 @@ public:
         boost::shared_ptr<IOAsioSocket<IOFetch> > socket;
                                                 ///< Socket to use for I/O
         boost::shared_ptr<IOEndpoint> remote;   ///< Where the fetch was sent
-        isc::dns::Question          question;   ///< Question to be asked
+        isc::dns::MessagePtr        query_message;///< Query message to be sent
         isc::dns::OutputBufferPtr   msgbuf;     ///< Wire buffer for question
         isc::dns::OutputBufferPtr   buffer;     ///< Received data held here
         boost::shared_array<char>   data;       ///< Temporary array for data
@@ -128,7 +128,6 @@ public:
         bool                        stopped;    ///< Have we stopped running?
         asio::deadline_timer        timer;      ///< Timer to measure timeouts
         int                         timeout;    ///< Timeout in ms
-        isc::dns::qid_t             qid;        ///< The QID set in the query
 
         /// \brief Constructor
         ///
@@ -149,7 +148,7 @@ public:
         ///
         /// TODO: May need to alter constructor (see comment 4 in Trac ticket #554)
         IOFetchData(int protocol, IOService& service,
-            const isc::dns::Question& query, const IOAddress& address,
+            isc::dns::MessagePtr query_msg, const IOAddress& address,
             uint16_t port, isc::dns::OutputBufferPtr& buff, Callback* cb,
             int wait)
             :
@@ -163,7 +162,7 @@ public:
                 static_cast<IOEndpoint*>(new UDPEndpoint(address, port)) :
                 static_cast<IOEndpoint*>(new TCPEndpoint(address, port))
                 ),
-            question(query),
+            query_message(query_msg),
             msgbuf(new isc::dns::OutputBuffer(512)),
             buffer(buff),
             data(new char[IOFetch::MAX_LENGTH]),
@@ -171,8 +170,7 @@ public:
             cumulative(0),
             stopped(false),
             timer(service.get_io_service()),
-            timeout(wait),
-            qid(QidGenerator::getInstance().generateQid())
+            timeout(wait)
         {}
     };
 
@@ -221,7 +219,6 @@ public:
 
 private:
     boost::shared_ptr<IOFetchData>  data_;   ///< Private data
-
 };
 
 } // namespace asiolink




More information about the bind10-changes mailing list