[svn] commit: r1187 - /trunk/src/lib/auth/data_source.cc
BIND 10 source code commits
bind10-changes at lists.isc.org
Sun Mar 7 22:54:00 UTC 2010
Author: each
Date: Sun Mar 7 22:54:00 2010
New Revision: 1187
Log:
- fixed a compile bug in code I accidentally committed earlier
- added a RETERR macro for readability
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 Sun Mar 7 22:54:00 2010
@@ -35,6 +35,12 @@
#include "data_source.h"
#include "query.h"
+
+#define RETERR(x) do { \
+ DataSrc::Result r = (x); \
+ if (r != DataSrc::SUCCESS) \
+ return (r); \
+ } while (0)
using namespace std;
using namespace isc::dns;
@@ -256,13 +262,12 @@
static inline DataSrc::Result
addSOA(Query& q, const Name* zonename, const DataSrc* ds) {
Message& m = q.message();
- DataSrc::Result result;
RRsetList soa;
QueryTask newtask(*zonename, q.qclass(), RRType::SOA(),
QueryTask::SIMPLE_QUERY);
- result = doQueryTask(ds, zonename, q, newtask, soa);
- if (result != DataSrc::SUCCESS || newtask.flags != 0) {
+ RETERR(doQueryTask(ds, zonename, q, newtask, soa));
+ if (newtask.flags != 0) {
return (DataSrc::ERROR);
}
@@ -276,15 +281,10 @@
{
RRsetList nsec;
Message& m = q.message();
- DataSrc::Result result;
QueryTask newtask(name, task->qclass, RRType::NSEC(),
QueryTask::SIMPLE_QUERY);
- result = doQueryTask(ds, &zonename, q, newtask, nsec);
- if (result != DataSrc::SUCCESS) {
- return (DataSrc::ERROR);
- }
-
+ RETERR(doQueryTask(ds, &zonename, q, newtask, nsec));
if (newtask.flags == 0) {
m.addRRset(Section::AUTHORITY(), nsec[RRType::NSEC()], true);
}
@@ -294,16 +294,10 @@
static inline DataSrc::Result
getNsec3(Query& q, const DataSrc* ds, const Name& zonename, string& hash,
- RRsetPtr target)
-{
- DataSrc::Result result;
+ RRsetPtr& target)
+{
RRsetList rl;
-
- result = ds->findCoveringNSEC3(q, zonename, hash, rl);
- if (result != DataSrc::SUCCESS) {
- return (result);
- }
-
+ RETERR(ds->findCoveringNSEC3(q, zonename, hash, rl));
target = rl[RRType::NSEC3()];
return (DataSrc::SUCCESS);
}
@@ -345,17 +339,12 @@
proveNX(Query& q, QueryTaskPtr task, const DataSrc* ds, const Name& zonename)
{
Message& m = q.message();
- DataSrc::Result result;
-
ConstNsec3ParamPtr nsec3 = getNsec3Param(q, ds, zonename);
if (nsec3 != NULL) {
// Attach the NSEC3 record covering the QNAME
RRsetPtr rrset;
- string hash1(nsec3->getHash(task->qname));
- result = getNsec3(q, ds, zonename, hash1, rrset);
- if (result != DataSrc::SUCCESS) {
- return (result);
- }
+ string hash1(nsec3->getHash(task->qname)), hash2;
+ RETERR(getNsec3(q, ds, zonename, hash1, rrset));
m.addRRset(Section::AUTHORITY(), rrset, true);
// If this is an NXRRSET or NOERROR/NODATA, we're done
@@ -378,11 +367,7 @@
// hash2 will be overwritten with the actual hash found;
// we don't want to use one until we find an exact match
- result = getNsec3(q, ds, zonename, hash2, rrset);
- if (result != DataSrc::SUCCESS) {
- return (DataSrc::ERROR);
- }
-
+ RETERR(getNsec3(q, ds, zonename, hash2, rrset));
if (hash2 == nodehash) {
m.addRRset(Section::AUTHORITY(), rrset, true);
break;
@@ -392,11 +377,8 @@
// Now add a covering NSEC3 for a wildcard under the
// closest provable enclosing name
string hash3(nsec3->getHash(Name("*").concatenate(enclosure)));
- if (wild != hash1 && wild != hash2) {
- result = getNsec3(q, ds, zonename, wild, rrset);
- if (result != DataSrc::SUCCESS) {
- return (result);
- }
+ RETERR(getNsec3(q, ds, zonename, hash3, rrset));
+ if (hash3 != hash1 && hash3 != hash2) {
m.addRRset(Section::AUTHORITY(), rrset, true);
}
} else {
@@ -405,21 +387,14 @@
ds->findPreviousName(q, task->qname, nsecname, &zonename);
}
- result = addNSEC(q, task, nsecname, zonename, ds);
- if (result != DataSrc::SUCCESS) {
- return (result);
- }
-
+ RETERR(addNSEC(q, task, nsecname, zonename, ds));
if ((task->flags & DataSrc::TYPE_NOT_FOUND) != 0 ||
nsecname == zonename)
{
return (DataSrc::SUCCESS);
}
- result = addNSEC(q, task, zonename, zonename, ds);
- if (result != DataSrc::SUCCESS) {
- return (result);
- }
+ RETERR(addNSEC(q, task, zonename, zonename, ds));
}
return (DataSrc::SUCCESS);
More information about the bind10-changes
mailing list