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

BIND 10 source code commits bind10-changes at lists.isc.org
Thu Feb 11 00:00:21 UTC 2010


Author: each
Date: Thu Feb 11 00:00:20 2010
New Revision: 797

Log:
checkpoint: fixed NXDOMAIN reply processing, improved query logic

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 Thu Feb 11 00:00:20 2010
@@ -48,19 +48,27 @@
                     m.addRRset(task.section, sigs[0]);
                 }
 
-                if (q.status() == QUERY_FINISHING) {
-                    q.setStatus(QUERY_DONE);
-                    return (SUCCESS);
+                switch (q.status()) {
+                    case QUERY_GETANSWER:
+                    case QUERY_GETADDITIONAL:
+                    case QUERY_GETCNAME:
+                        // if are no more work items, add authority section
+                        if (q.tasks().empty() &&
+                            data[0]->getType() != RRType("NS")) {
+                            q.tasks().push(QueryTask(Name(*match.closestName()),
+                                                     task.qclass, RRType("NS"),
+                                                     Section::AUTHORITY()));
+                            q.setStatus(QUERY_GETAUTHORITY);
+                        }
+                        continue;
+
+                    case QUERY_GETAUTHORITY:
+                        q.setStatus(QUERY_SUCCESS);
+                        return (SUCCESS);
+
+                    default:
+                        dns_throw (Unexpected, "unexpected query status");
                 }
-
-                // if there are no more work items, add the authority section
-                if (q.tasks().empty() && q.status() == QUERY_INCOMPLETE) {
-                    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]);
@@ -68,13 +76,19 @@
                     m.addRRset(task.section, sigs[0]);
                 }
 
-                // if (data[0].getType() == RRType::CNAME()) {
-                //     // take apart the CNAME rdata and re-query HERE
-                // }
+                if (data[0]->getType() == RRType("CNAME")) {
+                    // HERE pull out target name
+                    // q.tasks().push(QueryTask(cname_target, task.qclass,
+                    //                         task.qtype, Section::ANSWER()));
+                    q.setStatus(QUERY_GETCNAME);
+                } else {
+                    dns_throw (Unexpected, "unexpected query status");
+                }
                 continue;
 
             case NAME_NOT_FOUND:
                 q.setStatus(QUERY_NODATA);
+
                 if (q.wantDnssec()) {
                     result = ds->findRRset(Name(*match.closestName()),
                                            task.qclass, RRType::SOA(),
@@ -95,7 +109,7 @@
                 if (q.wantDnssec() && sigs.size() == 1) {
                     m.addRRset(Section::AUTHORITY(), sigs[0]);
                 }
-                break;
+                return (SUCCESS);
 
             case TYPE_NOT_FOUND:
                 m.setRcode(Rcode::NOERROR());

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 Thu Feb 11 00:00:20 2010
@@ -30,9 +30,11 @@
 namespace dns {
 
 enum QueryStatus {
-    QUERY_INCOMPLETE,
-    QUERY_FINISHING,
-    QUERY_DONE,
+    QUERY_GETANSWER,
+    QUERY_GETCNAME,
+    QUERY_GETADDITIONAL,
+    QUERY_GETAUTHORITY,
+    QUERY_SUCCESS,
     QUERY_NODATA
 };
 
@@ -71,7 +73,7 @@
         message_ = &m;
         want_additional = true;
         want_dnssec = dnssec;
-        status_ = QUERY_INCOMPLETE;
+        status_ = QUERY_GETANSWER;
 
         // Check message formatting
         QuestionIterator qid = message_->beginQuestion();




More information about the bind10-changes mailing list