[svn] commit: r1728 - /trunk/src/lib/auth/data_source.cc

BIND 10 source code commits bind10-changes at lists.isc.org
Sat Apr 17 00:58:39 UTC 2010


Author: jinmei
Date: Sat Apr 17 00:58:39 2010
New Revision: 1728

Log:
cleanup/simplification:
- remove an unnecessary temporary variable to shorten a method
- use RRClass instead of Query when the former suffices to reduce dependency

build/tests okay, no behavioral change.  skipping explicit review.

Modified:
    trunk/src/lib/auth/data_source.cc

Modified: trunk/src/lib/auth/data_source.cc
==============================================================================
--- trunk/src/lib/auth/data_source.cc (original)
+++ trunk/src/lib/auth/data_source.cc Sat Apr 17 00:58:39 2010
@@ -57,7 +57,7 @@
 // Add a task to the query task queue to look up additional data
 // (i.e., address records for the names included in NS or MX records)
 void
-getAdditional(Query& q, RRsetPtr rrset) {
+getAdditional(Query& q, ConstRRsetPtr rrset) {
     if (!q.wantAdditional()) {
         return;
     }
@@ -65,24 +65,20 @@
     RdataIteratorPtr it = rrset->getRdataIterator();
     for (it->first(); !it->isLast(); it->next()) {
         const Rdata& rd(it->getCurrent());
-        QueryTaskPtr newtask = QueryTaskPtr();
-
         if (rrset->getType() == RRType::NS()) {
             const generic::NS& ns = dynamic_cast<const generic::NS&>(rd);
-
-            newtask = QueryTaskPtr(new QueryTask(ns.getNSName(), q.qclass(),
-                                                 Section::ADDITIONAL(),
-                                                 QueryTask::GLUE_QUERY,
-                                                 QueryTask::GETADDITIONAL)); 
+            q.tasks().push(QueryTaskPtr(
+                               new QueryTask(ns.getNSName(), q.qclass(),
+                                             Section::ADDITIONAL(),
+                                             QueryTask::GLUE_QUERY,
+                                             QueryTask::GETADDITIONAL))); 
         } else if (rrset->getType() == RRType::MX()) {
             const generic::MX& mx = dynamic_cast<const generic::MX&>(rd);
-            newtask = QueryTaskPtr(new QueryTask(mx.getMXName(), q.qclass(),
-                                                 Section::ADDITIONAL(),
-                                                 QueryTask::NOGLUE_QUERY,
-                                                 QueryTask::GETADDITIONAL)); 
-        }
-        if (newtask) {
-            q.tasks().push(newtask);
+            q.tasks().push(QueryTaskPtr(
+                               new QueryTask(mx.getMXName(), q.qclass(),
+                                             Section::ADDITIONAL(),
+                                             QueryTask::NOGLUE_QUERY,
+                                             QueryTask::GETADDITIONAL))); 
         }
     }
 }
@@ -187,10 +183,10 @@
 
 // Query for referrals (i.e., NS/DS or DNAME) at a given name
 inline bool
-refQuery(const Name& name, Query& q, const DataSrc* ds, const Name* zonename,
-         RRsetList& target)
-{
-    QueryTask newtask(name, q.qclass(), QueryTask::REF_QUERY);
+refQuery(const Name& name, const RRClass& qclass, const DataSrc* ds,
+         const Name* zonename, RRsetList& target)
+{
+    QueryTask newtask(name, qclass, QueryTask::REF_QUERY);
 
     if (doQueryTask(ds, zonename, newtask, target) != DataSrc::SUCCESS) {
         // Lookup failed
@@ -218,7 +214,7 @@
         RRsetList ref;
         for (int i = diff; i > 1; --i) {
             const Name sub(task->qname.split(i - 1, nlen - i));
-            if (refQuery(sub, q, ds, zonename, ref)) {
+            if (refQuery(sub, q.qclass(), ds, zonename, ref)) {
                 found = true;
                 break;
             }
@@ -502,7 +498,7 @@
             }
 
             RRsetList auth;
-            if (! refQuery(*zonename, q, ds, zonename, auth)) {
+            if (!refQuery(*zonename, q.qclass(), ds, zonename, auth)) {
                 return (DataSrc::ERROR);
             }
 
@@ -618,7 +614,8 @@
                     // Add the NS records for the enclosing zone to
                     // the authority section.
                     RRsetList auth;
-                    if (!refQuery(*zonename, q, datasource, zonename, auth)) {
+                    if (!refQuery(*zonename, q.qclass(), datasource, zonename,
+                                  auth)) {
                         m.setRcode(Rcode::SERVFAIL());
                         return;
                     }
@@ -661,7 +658,8 @@
             if (task->state == QueryTask::GETANSWER) {
                 RRsetList auth;
                 m.clearHeaderFlag(MessageFlag::AA());
-                if (!refQuery(task->qname, q, datasource, zonename, auth)) {
+                if (!refQuery(task->qname, q.qclass(), datasource, zonename,
+                              auth)) {
                     m.setRcode(Rcode::SERVFAIL());
                     return;
                 }




More information about the bind10-changes mailing list