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

BIND 10 source code commits bind10-changes at lists.isc.org
Wed Feb 17 01:39:25 UTC 2010


Author: each
Date: Wed Feb 17 01:39:25 2010
New Revision: 847

Log:
- removed GETAUTHORITY task state, it was never used (also added comment
  explaining why it's never used)
- refactored some parts of DataSrc::doQuery() to take advantage of new
  RRsetList features

Modified:
    branches/each-ds/src/lib/auth/cpp/data_source.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 17 01:39:25 2010
@@ -171,18 +171,17 @@
 
                         if (found) {
                             BOOST_FOREACH (RRsetPtr r, ref) {
-                                if (r->getType() == RRType::NS()) {
-                                    // XXX: eventually also handle DS
-                                    m.addRRset(Section::AUTHORITY(), r);
-                                    getAdditional(q, r);
-                                } else if (r->getType() == RRType::DNAME()) {
+                                if (r->getType() == RRType::DNAME()) {
+                                    RRsetList syn;
                                     m.addRRset(Section::ANSWER(), r);
-                                    RRsetList syn;
                                     synthesizeCname(q, task, r, syn);
                                     if (syn.size() == 1) {
                                         m.addRRset(Section::ANSWER(), syn[0]);
                                         chaseCname(q, task, syn[0]);
                                     }
+                                } else {
+                                    m.addRRset(Section::AUTHORITY(), r);
+                                    getAdditional(q, r);
                                 }
                             }
                             continue;
@@ -252,17 +251,6 @@
                 }
                 continue;
 
-            case QueryTask::GETAUTHORITY:
-                BOOST_FOREACH(RRsetPtr rrset, data) {
-                    m.addRRset(task.section, rrset);
-                    getAdditional(q, rrset);
-                }
-                if (q.tasks().empty()) {
-                    q.setStatus(Query::SUCCESS);
-                    return;
-                }
-                continue;
-
             case QueryTask::GETADDITIONAL:
                 BOOST_FOREACH(RRsetPtr rrset, data) {
                     if (q.status() == Query::ANSWERED &&
@@ -285,13 +273,10 @@
         case CNAME_FOUND:
             // The qname node contains a CNAME.  Add a new task to the
             // queue to look up its target.
-            if (data.size() != 1 ||
-                data[0]->getType() != RRType::CNAME()) {
-                dns_throw (Unexpected, "invalid data");
-            }
-
-            m.addRRset(task.section, data[0]);
-            chaseCname(q, task, data[0]);
+            if (RRsetPtr rrset = data[RRType::CNAME()]) {
+                m.addRRset(task.section, rrset);
+                chaseCname(q, task, rrset);
+            }
             continue;
 
         case REFERRAL_FOUND:
@@ -352,30 +337,33 @@
                         // only be one rrset returned in wild.  But
                         // eventually this will need to handle ANY queries,
                         // so wrap it in a BOOST_FOREACH statement anyway.
-                        BOOST_FOREACH (RRsetPtr rrset, wild) {
-                            rrset->setName(task.qname);
-                            m.addRRset(Section::ANSWER(), rrset);
-
-                            if (r == CNAME_FOUND &&
-                                q.qtype() != RRType::ANY()) {
+                        if (r == CNAME_FOUND) {
+                            if (RRsetPtr rrset = wild[RRType::CNAME()]) {
+                                rrset->setName(task.qname);
+                                m.addRRset(Section::ANSWER(), rrset);
                                 chaseCname(q, task, rrset);
-                            } else {
-                                RRsetList auth;
-                                QueryTask t(Name(*zone), task.qclass,
-                                            QueryTask::REF_QUERY); 
-                                r = doQueryTask(ds, q, t, auth);
-                                if (r != SUCCESS) {
-                                    m.setRcode(Rcode::SERVFAIL());
-                                    return;
+                            }
+                        } else {
+                            BOOST_FOREACH (RRsetPtr rrset, wild) {
+                                rrset->setName(task.qname);
+                                m.addRRset(Section::ANSWER(), rrset);
+                            }
+
+                            RRsetList auth;
+                            QueryTask t(Name(*zone), task.qclass,
+                                        QueryTask::REF_QUERY); 
+                            r = doQueryTask(ds, q, t, auth);
+                            if (r != SUCCESS) {
+                                m.setRcode(Rcode::SERVFAIL());
+                                return;
+                            }
+
+                            BOOST_FOREACH (RRsetPtr rrset, auth) {
+                                if (rrset->getType() == RRType::DNAME()) {
+                                    continue;
                                 }
-
-                                BOOST_FOREACH (RRsetPtr rrset, auth) {
-                                    if (rrset->getType() == RRType::DNAME()) {
-                                        continue;
-                                    }
-                                    m.addRRset(Section::AUTHORITY(), rrset);
-                                    getAdditional(q, rrset);
-                                }
+                                m.addRRset(Section::AUTHORITY(), rrset);
+                                getAdditional(q, rrset);
                             }
                         }
                         continue;

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 17 01:39:25 2010
@@ -82,24 +82,26 @@
     //   (The qname of the task should exactly match the qname of the
     //   query.)  If we have no match, the query has failed.
     //
+    // - GETADDITIONAL: We are filling in additional data, either
+    //   as a result of finding NS or MX records via a GETANSWER
+    //   query task, or as a result of finding NS records when
+    //   getting authority-section data.
+    //
     // - FOLLOWCNAME: We are looking for the target of a CNAME RR that
     //   was found via a previous GETANSWER query task.  If we have no
     //   match, the query is still successful.
     //
-    // - GETAUTHORITY: We are looking for the authority information.
-    //   If a complete answer was previously found, this might be a
-    //   query for NS records.  If no complete answer has been found,
-    //   this might be a query for an SOA, NSEC or NSEC3 records.
-    //
-    // - GETADDITIONAL: We are filling in additional data, either
-    //   as a result of finding NS or MX records via a GETANSWER
-    //   query task, or as a result of finding NS records via a
-    //   GETAUTHORITY query task.
+    // (NOTE: It is only necessary to set a task state when pushing
+    // tasks onto the query task queue, which in turn is only necessary
+    // when it's uncertain which data source will be authoritative for the
+    // data.  That's why there is no GETAUTHORITY task state; when
+    // processing an answer, either positive or negative, the authoritative
+    // data source will already have been discovered, and can be queried
+    // directly.)
 
     enum State {
         GETANSWER,
         GETADDITIONAL,
-        GETAUTHORITY,
         FOLLOWCNAME
     } state;
 




More information about the bind10-changes mailing list