[svn] commit: r779 - in /branches/each-ds/src/lib/auth/cpp: data_source.cc data_source.h data_source_sqlite3.cc query.cc query.h

BIND 10 source code commits bind10-changes at lists.isc.org
Wed Feb 10 05:41:48 UTC 2010


Author: each
Date: Wed Feb 10 05:41:47 2010
New Revision: 779

Log:
checkpoint: adding NS queries in authority section now works correctly

Modified:
    branches/each-ds/src/lib/auth/cpp/data_source.cc
    branches/each-ds/src/lib/auth/cpp/data_source.h
    branches/each-ds/src/lib/auth/cpp/data_source_sqlite3.cc
    branches/each-ds/src/lib/auth/cpp/query.cc
    branches/each-ds/src/lib/auth/cpp/query.h

Modified: branches/each-ds/src/lib/auth/cpp/data_source.cc
==============================================================================
--- branches/each-ds/src/lib/auth/cpp/data_source.cc (original)
+++ branches/each-ds/src/lib/auth/cpp/data_source.cc Wed Feb 10 05:41:47 2010
@@ -15,38 +15,37 @@
 DSResult
 DataSrc::runQuery(Query q) {
     DSResult result;
-    Name container(".");
     Message& m = q.message();
 
     while (!q.tasks().empty()) {
         RRsetList data, sigs;
-        QueryTaskPtr task = q.tasks().front();
+        QueryTask task = q.tasks().front();
         q.tasks().pop();
 
-        NameMatch match(task->qname);
+        NameMatch match(task.qname);
         findClosestEnclosure(match);
         const DataSrc* ds = match.bestDataSrc();
 
         if (ds == NULL) {
             result = ZONE_NOT_FOUND;
         } else if (q.wantDnssec()) {
-            result = ds->findRRset(task->qname, task->qclass, task->qtype,
+            result = ds->findRRset(task.qname, task.qclass, task.qtype,
                                    data, sigs);
             // XXX validity check:
             // for now, there must only be exactly one RRset in data
             // and no more than one RRset in sigs.  the rrtype of data
             // must match the sigtype of sigs, if any
         } else {
-            result = ds->findRRset(task->qname, task->qclass, task->qtype,
+            result = ds->findRRset(task.qname, task.qclass, task.qtype,
                                    data);
         }
 
         switch (result) {
             case SUCCESS:
                 // XXX: what if 'data' contains more than one RRset?
-                m.addRRset(task->section, data[0]);
+                m.addRRset(task.section, data[0]);
                 if (q.wantDnssec() && sigs.size() == 1) {
-                    m.addRRset(task->section, sigs[0]);
+                    m.addRRset(task.section, sigs[0]);
                 }
 
                 if (q.status() == QUERY_FINISHING) {
@@ -56,18 +55,17 @@
 
                 // if there are no more work items, add the authority section
                 if (q.tasks().empty() && q.status() == QUERY_INCOMPLETE) {
-                    QueryTask *qt = new QueryTask(container, task->qclass,
-                                                  RRType::NS(),
-                                                  Section::AUTHORITY());
-                    q.tasks().push(QueryTaskPtr(qt));
+                    q.tasks().push(QueryTask(Name(*match.closestName()),
+                                             task.qclass, RRType::NS(),
+                                             Section::AUTHORITY()));
                     q.setStatus(QUERY_FINISHING);
                 }
                 continue;
 
             case CNAME:
-                m.addRRset(task->section, data[0]);
+                m.addRRset(task.section, data[0]);
                 if (q.wantDnssec() && sigs.size() == 1) {
-                    m.addRRset(task->section, sigs[0]);
+                    m.addRRset(task.section, sigs[0]);
                 }
 
                 // if (data[0].getType() == RRType::CNAME()) {
@@ -78,11 +76,13 @@
             case NAME_NOT_FOUND:
                 q.setStatus(QUERY_NODATA);
                 if (q.wantDnssec()) {
-                    result = ds->findRRset(container, task->qclass,
-                                           RRType::SOA(), data, sigs);
+                    result = ds->findRRset(Name(*match.closestName()),
+                                           task.qclass, RRType::SOA(),
+                                           data, sigs);
                 } else {
-                    result = ds->findRRset(container, task->qclass, 
-                                           RRType::SOA(), data);
+                    result = ds->findRRset(Name(*match.closestName()),
+                                           task.qclass, RRType::SOA(),
+                                           data);
                 }
 
                 if (result != SUCCESS) {

Modified: branches/each-ds/src/lib/auth/cpp/data_source.h
==============================================================================
--- branches/each-ds/src/lib/auth/cpp/data_source.h (original)
+++ branches/each-ds/src/lib/auth/cpp/data_source.h Wed Feb 10 05:41:47 2010
@@ -185,11 +185,13 @@
     NameMatch(const Name& qname) :
         closest_name_(NULL), best_source_(NULL), qname_(qname) {}
 
-    ~NameMatch() {}
+    ~NameMatch() {
+        delete closest_name_;
+    }
 
     void update(const DataSrc& new_source, const Name& container) {
         if (closest_name_ == NULL) {
-            closest_name_ = &container;
+            closest_name_ = new Name(container);
             best_source_ = &new_source;
             return;
         }
@@ -198,7 +200,9 @@
             container.compare(*closest_name_).getRelation();
 
         if (cmp == NameComparisonResult::SUBDOMAIN) {
-            closest_name_ = &container;
+            Name* newname = new Name(container);
+            delete closest_name_;
+            closest_name_ = newname;
             best_source_ = &new_source;
         }
     }

Modified: branches/each-ds/src/lib/auth/cpp/data_source_sqlite3.cc
==============================================================================
--- branches/each-ds/src/lib/auth/cpp/data_source_sqlite3.cc (original)
+++ branches/each-ds/src/lib/auth/cpp/data_source_sqlite3.cc Wed Feb 10 05:41:47 2010
@@ -264,7 +264,6 @@
 Sqlite3DataSrc::findClosestEnclosure(NameMatch& match) const {
     const Name& qname = match.qname();
     const string target_string = qname.toText();
-
     const char *position = NULL;
     
     int ret = findClosest(target_string.c_str(), &position);
@@ -277,9 +276,9 @@
 
 DSResult
 Sqlite3DataSrc::findRRset(const Name& qname,
-                         const RRClass& qclass,
-                         const RRType& qtype,
-                         RRsetList& target) const
+                          const RRClass& qclass,
+                          const RRType& qtype,
+                          RRsetList& target) const
 {
     int rows = findRecords(qname, qtype, target);
     if (rows == 0) {
@@ -291,9 +290,9 @@
 
 DSResult
 Sqlite3DataSrc::findRRset(const Name& qname,
-                         const RRClass& qclass,
-                         const RRType& qtype,
-                         RRsetList& target, RRsetList& sigs) const
+                          const RRClass& qclass,
+                          const RRType& qtype,
+                          RRsetList& target, RRsetList& sigs) const
 {
     return (findRRset(qname, qclass, qtype, target));
 }

Modified: branches/each-ds/src/lib/auth/cpp/query.cc
==============================================================================
--- branches/each-ds/src/lib/auth/cpp/query.cc (original)
+++ branches/each-ds/src/lib/auth/cpp/query.cc Wed Feb 10 05:41:47 2010
@@ -26,18 +26,5 @@
 namespace isc {
 namespace dns {
 
-QueryTask::QueryTask(const Name& n, const RRClass& c,
-                     const RRType& t, const Section& s) :
-    qname(n), qclass(c), qtype(t), section(s)
-{
-        // Empty constructor.  It is defined outside the class statement
-        // because otherwise the linker will be confused.
-}
-
-QueryTask::~QueryTask() {
-        // Empty destructor.  It is defined outside the class statement
-        // because otherwise the linker will be confused.
-}
-
 }
 }

Modified: branches/each-ds/src/lib/auth/cpp/query.h
==============================================================================
--- branches/each-ds/src/lib/auth/cpp/query.h (original)
+++ branches/each-ds/src/lib/auth/cpp/query.h Wed Feb 10 05:41:47 2010
@@ -49,17 +49,17 @@
 class QueryTask {
 public:
     QueryTask(const Name& n, const RRClass& c,
-              const RRType& t, const Section& s);
-    virtual ~QueryTask();
+              const RRType& t, const Section& s) :
+        qname(n), qclass(c), qtype(t), section(s) {}
+    virtual ~QueryTask() {}
 
-    const Name& qname;
+    const Name qname;
     const RRClass& qclass;
     const RRType& qtype;
     const Section& section;
 };
 
-typedef boost::shared_ptr<QueryTask> QueryTaskPtr;
-typedef std::queue<QueryTaskPtr> QueryTaskQueue;
+typedef std::queue<QueryTask> QueryTaskQueue;
 
 class Query;
 typedef boost::shared_ptr<Query> QueryPtr;
@@ -84,8 +84,8 @@
         qname_ = &query->getName();
         qclass_ = &query->getClass();
         qtype_ = &query->getType();
-        querytasks.push(QueryTaskPtr(new QueryTask(*qname_, *qclass_,
-                                     *qtype_, Section::ANSWER())));
+        querytasks.push(QueryTask(*qname_, *qclass_, *qtype_,
+                                  Section::ANSWER()));
     };
 
     virtual ~Query() {}




More information about the bind10-changes mailing list