[svn] commit: r2363 - in /branches/trac192/src: bin/auth/auth_srv.cc bin/auth/auth_srv.h bin/auth/main.cc bin/bind10/bind10.py.in lib/datasrc/data_source.cc lib/datasrc/tests/datasrc_unittest.cc
BIND 10 source code commits
bind10-changes at lists.isc.org
Wed Jun 30 19:02:22 UTC 2010
Author: each
Date: Wed Jun 30 19:02:22 2010
New Revision: 2363
Log:
- Fixed a bug in getCache() that could cause duplicate additional section data
- Added test to check that two successive queries to a cache-enabled
data source get the same result. (Should do more like this in future work.)
- Added a command line option to disable the hot-spot cache
Modified:
branches/trac192/src/bin/auth/auth_srv.cc
branches/trac192/src/bin/auth/auth_srv.h
branches/trac192/src/bin/auth/main.cc
branches/trac192/src/bin/bind10/bind10.py.in
branches/trac192/src/lib/datasrc/data_source.cc
branches/trac192/src/lib/datasrc/tests/datasrc_unittest.cc
Modified: branches/trac192/src/bin/auth/auth_srv.cc
==============================================================================
--- branches/trac192/src/bin/auth/auth_srv.cc (original)
+++ branches/trac192/src/bin/auth/auth_srv.cc Wed Jun 30 19:02:22 2010
@@ -60,7 +60,7 @@
AuthSrvImpl(const AuthSrvImpl& source);
AuthSrvImpl& operator=(const AuthSrvImpl& source);
public:
- AuthSrvImpl();
+ AuthSrvImpl(const bool use_cache);
isc::data::ElementPtr setDbFile(const isc::data::ElementPtr config);
@@ -81,7 +81,7 @@
isc::datasrc::HotCache cache_;
};
-AuthSrvImpl::AuthSrvImpl() : cs_(NULL), verbose_mode_(false)
+AuthSrvImpl::AuthSrvImpl(const bool use_cache) : cs_(NULL), verbose_mode_(false)
{
// cur_datasrc_ is automatically initialized by the default constructor,
// effectively being an empty (sqlite) data source. once ccsession is up
@@ -89,9 +89,12 @@
// add static data source
data_sources_.addDataSrc(ConstDataSrcPtr(new StaticDataSrc));
-}
-
-AuthSrv::AuthSrv() : impl_(new AuthSrvImpl) {
+
+ // enable or disable the cache
+ cache_.setEnabled(use_cache);
+}
+
+AuthSrv::AuthSrv(const bool use_cache) : impl_(new AuthSrvImpl(use_cache)) {
}
AuthSrv::~AuthSrv() {
Modified: branches/trac192/src/bin/auth/auth_srv.h
==============================================================================
--- branches/trac192/src/bin/auth/auth_srv.h (original)
+++ branches/trac192/src/bin/auth/auth_srv.h Wed Jun 30 19:02:22 2010
@@ -43,7 +43,7 @@
AuthSrv(const AuthSrv& source);
AuthSrv& operator=(const AuthSrv& source);
public:
- explicit AuthSrv();
+ explicit AuthSrv(const bool use_cache = true);
~AuthSrv();
//@}
/// \return \c true if the \message contains a response to be returned;
Modified: branches/trac192/src/bin/auth/main.cc
==============================================================================
--- branches/trac192/src/bin/auth/main.cc (original)
+++ branches/trac192/src/bin/auth/main.cc Wed Jun 30 19:02:22 2010
@@ -696,7 +696,7 @@
void
usage() {
- cerr << "Usage: b10-auth [-p port] [-4|-6]" << endl;
+ cerr << "Usage: b10-auth [-p port] [-4|-6] [-nv]" << endl;
exit(1);
}
} // end of anonymous namespace
@@ -705,9 +705,9 @@
main(int argc, char* argv[]) {
int ch;
const char* port = DNSPORT;
- bool use_ipv4 = true, use_ipv6 = true;
-
- while ((ch = getopt(argc, argv, "46p:v")) != -1) {
+ bool use_ipv4 = true, use_ipv6 = true, cache = true;
+
+ while ((ch = getopt(argc, argv, "46np:v")) != -1) {
switch (ch) {
case '4':
// Note that -4 means "ipv4 only", we need to set "use_ipv6" here,
@@ -720,6 +720,9 @@
// The same note as -4 applies.
use_ipv4 = false;
break;
+ case 'n':
+ cache = false;
+ break;
case 'p':
port = optarg;
break;
@@ -752,7 +755,7 @@
specfile = string(AUTH_SPECFILE_LOCATION);
}
- auth_server = new AuthSrv;
+ auth_server = new AuthSrv(cache);
auth_server->setVerbose(verbose_mode);
#ifdef HAVE_BOOST_SYSTEM
Modified: branches/trac192/src/bin/bind10/bind10.py.in
==============================================================================
--- branches/trac192/src/bin/bind10/bind10.py.in (original)
+++ branches/trac192/src/bin/bind10/bind10.py.in Wed Jun 30 19:02:22 2010
@@ -158,7 +158,7 @@
class BoB:
"""Boss of BIND class."""
- def __init__(self, c_channel_port=9912, auth_port=5300, verbose=False):
+ def __init__(self, c_channel_port=9912, auth_port=5300, nocache=False, verbose=False):
"""Initialize the Boss of BIND. This is a singleton (only one
can run).
@@ -174,6 +174,7 @@
self.processes = {}
self.dead_processes = {}
self.runnable = False
+ self.nocache = nocache
os.environ['ISC_MSGQ_PORT'] = str(self.c_channel_port)
@@ -302,6 +303,8 @@
# start b10-auth
# XXX: this must be read from the configuration manager in the future
authargs = ['b10-auth', '-p', str(self.auth_port)]
+ if self.nocache:
+ authargs += ['-n']
if self.verbose:
sys.stdout.write("Starting b10-auth using port %d\n" %
self.auth_port)
@@ -585,6 +588,8 @@
parser.add_option("-m", "--msgq-port", dest="msgq_port", type="string",
action="callback", callback=check_port, default="9912",
help="port the b10-msgq daemon will use (default 9912)")
+ parser.add_option("-n", "--no-cache", action="store_true", dest="nocache",
+ default=False, help="disable hot-spot cache in b10-auth")
(options, args) = parser.parse_args()
# Announce startup.
@@ -608,7 +613,7 @@
# Go bob!
boss_of_bind = BoB(int(options.msgq_port), int(options.auth_port),
- options.verbose)
+ options.nocache, options.verbose)
startup_result = boss_of_bind.startup()
if startup_result:
sys.stderr.write("Error on startup: %s\n" % startup_result)
Modified: branches/trac192/src/lib/datasrc/data_source.cc
==============================================================================
--- branches/trac192/src/lib/datasrc/data_source.cc (original)
+++ branches/trac192/src/lib/datasrc/data_source.cc Wed Jun 30 19:02:22 2010
@@ -191,10 +191,9 @@
if (hit) {
if (rrset) {
rrsets.addRRset(rrset);
- }
-
+ target.append(rrsets);
+ }
task.flags = flags;
- target.append(rrsets);
return (true);
}
break;
@@ -213,10 +212,9 @@
if (hit) {
if (rrset) {
rrsets.addRRset(rrset);
- }
-
+ target.append(rrsets);
+ }
task.flags = flags;
- target.append(rrsets);
return (true);
}
break;
@@ -224,7 +222,7 @@
case QueryTask::GLUE_QUERY: // Find addresses
case QueryTask::NOGLUE_QUERY:
// (XXX: need to figure out how to deal with noglue case)
- flags = 0;
+ flags = count = 0;
hit = cache.retrieve(task.qname, task.qclass, RRType::A(),
rrset, cflags);
@@ -251,16 +249,16 @@
if (count == 2) {
if (found) {
flags &= ~DataSrc::TYPE_NOT_FOUND;
+ target.append(rrsets);
}
task.flags = flags;
- target.append(rrsets);
- return (DataSrc::SUCCESS);
+ return (true);
}
break;
case QueryTask::REF_QUERY: // Find NS, DS and/or DNAME
- flags = 0;
+ flags = count = 0;
hit = cache.retrieve(task.qname, task.qclass, RRType::NS(),
rrset, cflags);
@@ -299,8 +297,8 @@
if (found) {
flags &= ~DataSrc::TYPE_NOT_FOUND;
flags &= DataSrc::REFERRAL;
- }
- target.append(rrsets);
+ target.append(rrsets);
+ }
task.flags = flags;
return (true);
}
Modified: branches/trac192/src/lib/datasrc/tests/datasrc_unittest.cc
==============================================================================
--- branches/trac192/src/lib/datasrc/tests/datasrc_unittest.cc (original)
+++ branches/trac192/src/lib/datasrc/tests/datasrc_unittest.cc Wed Jun 30 19:02:22 2010
@@ -214,6 +214,48 @@
EXPECT_TRUE(it->isLast());
}
+// Make sure two successive queries have the same result
+TEST_F(DataSrcTest, DuplicateQuery) {
+ readAndProcessQuery("q_example_ns");
+ headerCheck(msg, Rcode::NOERROR(), true, true, true, 4, 0, 6);
+
+ RRsetIterator rit = msg.beginSection(Section::ANSWER());
+ RRsetPtr rrset = *rit;
+ EXPECT_EQ(Name("example.com"), rrset->getName());
+ EXPECT_EQ(RRType::NS(), rrset->getType());
+ EXPECT_EQ(RRClass::IN(), rrset->getClass());
+
+ RdataIteratorPtr it = rrset->getRdataIterator();
+ it->first();
+ EXPECT_EQ("dns01.example.com.", it->getCurrent().toText());
+ it->next();
+ EXPECT_EQ("dns02.example.com.", it->getCurrent().toText());
+ it->next();
+ EXPECT_EQ("dns03.example.com.", it->getCurrent().toText());
+ it->next();
+ EXPECT_TRUE(it->isLast());
+
+ msg.clear(Message::PARSE);
+ readAndProcessQuery("q_example_ns");
+ headerCheck(msg, Rcode::NOERROR(), true, true, true, 4, 0, 6);
+
+ rit = msg.beginSection(Section::ANSWER());
+ rrset = *rit;
+ EXPECT_EQ(Name("example.com"), rrset->getName());
+ EXPECT_EQ(RRType::NS(), rrset->getType());
+ EXPECT_EQ(RRClass::IN(), rrset->getClass());
+
+ it = rrset->getRdataIterator();
+ it->first();
+ EXPECT_EQ("dns01.example.com.", it->getCurrent().toText());
+ it->next();
+ EXPECT_EQ("dns02.example.com.", it->getCurrent().toText());
+ it->next();
+ EXPECT_EQ("dns03.example.com.", it->getCurrent().toText());
+ it->next();
+ EXPECT_TRUE(it->isLast());
+}
+
TEST_F(DataSrcTest, DNSKEYQuery) {
readAndProcessQuery("q_example_dnskey");
headerCheck(msg, Rcode::NOERROR(), true, true, true, 4, 4, 6);
More information about the bind10-changes
mailing list