[svn] commit: r3929 - in /branches/trac439/src/bin/auth: Makefile.am auth.spec.pre.in auth_srv.cc auth_srv.h benchmarks/Makefile.am benchmarks/query_bench.cc query.cc
BIND 10 source code commits
bind10-changes at lists.isc.org
Tue Dec 21 11:19:56 UTC 2010
Author: chenzhengzhang
Date: Tue Dec 21 11:19:56 2010
New Revision: 3929
Log:
update AuthSrvImpl::processNormalQuery()
Modified:
branches/trac439/src/bin/auth/Makefile.am
branches/trac439/src/bin/auth/auth.spec.pre.in
branches/trac439/src/bin/auth/auth_srv.cc
branches/trac439/src/bin/auth/auth_srv.h
branches/trac439/src/bin/auth/benchmarks/Makefile.am
branches/trac439/src/bin/auth/benchmarks/query_bench.cc
branches/trac439/src/bin/auth/query.cc
Modified: branches/trac439/src/bin/auth/Makefile.am
==============================================================================
--- branches/trac439/src/bin/auth/Makefile.am (original)
+++ branches/trac439/src/bin/auth/Makefile.am Tue Dec 21 11:19:56 2010
@@ -53,10 +53,10 @@
endif
libasio_link_a_CPPFLAGS = $(AM_CPPFLAGS)
-BUILT_SOURCES = spec_config.h
+BUILT_SOURCES = spec_config.h
pkglibexec_PROGRAMS = b10-auth
-b10_auth_SOURCES = auth_srv.cc auth_srv.h
-b10_auth_SOURCES += query.cc query.h
+b10_auth_SOURCES = query.cc query.h
+b10_auth_SOURCES += auth_srv.cc auth_srv.h
b10_auth_SOURCES += change_user.cc change_user.h
b10_auth_SOURCES += common.h
b10_auth_SOURCES += main.cc
Modified: branches/trac439/src/bin/auth/auth.spec.pre.in
==============================================================================
--- branches/trac439/src/bin/auth/auth.spec.pre.in (original)
+++ branches/trac439/src/bin/auth/auth.spec.pre.in Tue Dec 21 11:19:56 2010
@@ -3,6 +3,11 @@
"module_name": "Auth",
"module_description": "Authoritative service",
"config_data": [
+ { "item_name": "use_memory_datasrc",
+ "item_type": "boolean",
+ "item_optional": true,
+ "item_default": true
+ },
{ "item_name": "database_file",
"item_type": "string",
"item_optional": true,
Modified: branches/trac439/src/bin/auth/auth_srv.cc
==============================================================================
--- branches/trac439/src/bin/auth/auth_srv.cc (original)
+++ branches/trac439/src/bin/auth/auth_srv.cc Tue Dec 21 11:19:56 2010
@@ -42,6 +42,7 @@
#include <datasrc/data_source.h>
#include <datasrc/static_datasrc.h>
#include <datasrc/sqlite3_datasrc.h>
+#include <datasrc/memory_datasrc.h>
#include <cc/data.h>
@@ -50,6 +51,7 @@
#include <auth/common.h>
#include <auth/auth_srv.h>
#include <auth/asio_link.h>
+#include <auth/query.h>
using namespace std;
@@ -57,6 +59,7 @@
using namespace isc::cc;
using namespace isc::datasrc;
using namespace isc::dns;
+using namespace isc::auth;
using namespace isc::dns::rdata;
using namespace isc::data;
using namespace isc::config;
@@ -71,7 +74,7 @@
public:
AuthSrvImpl(const bool use_cache, AbstractXfroutClient& xfrout_client);
~AuthSrvImpl();
- isc::data::ConstElementPtr setDbFile(isc::data::ConstElementPtr config);
+ isc::data::ConstElementPtr setConfig(isc::data::ConstElementPtr config);
bool processNormalQuery(const IOMessage& io_message, Message& message,
MessageRenderer& response_renderer);
@@ -99,6 +102,12 @@
/// Hot spot cache
isc::datasrc::HotCache cache_;
+
+ /// Currently, MemoryDataSrc isn't a derived class of AbstractDataSrc
+ /// because the interface is so different, so we use a separate variable
+ /// here.
+ bool use_memory_datasrc_;
+ isc::datasrc::MemoryDataSrc memory_datasrc_;
};
AuthSrvImpl::AuthSrvImpl(const bool use_cache,
@@ -321,8 +330,16 @@
}
try {
- Query query(message, cache_, dnssec_ok);
- data_sources_.doQuery(query);
+ if (use_memory_datasrc_) {
+ ConstQuestionPtr question = *message.beginQuestion();
+ const RRType& qtype = question->getType();
+ const Name& qname = question->getName();
+ isc::auth::Query query(memory_datasrc_, qname, qtype, message);
+ query.process();
+ } else {
+ isc::datasrc::Query query(message, cache_, dnssec_ok);
+ data_sources_.doQuery(query);
+ }
} catch (const Exception& ex) {
if (verbose_mode_) {
cerr << "[b10-auth] Internal error, returning SERVFAIL: " <<
@@ -478,15 +495,24 @@
}
ConstElementPtr
-AuthSrvImpl::setDbFile(ConstElementPtr config) {
+AuthSrvImpl::setConfig(ConstElementPtr config) {
ConstElementPtr answer = isc::config::createAnswer();
- if (config && config->contains("database_file")) {
- db_file_ = config->get("database_file")->stringValue();
+ if (config) {
+ if (config->contains("database_file")) {
+ db_file_ = config->get("database_file")->stringValue();
+ }
+ if (config->contains("use_memory_datasrc")) {
+ use_memory_datasrc_ = config->get("use_memory_datasrc")->boolValue();
+ }
} else if (config_session_ != NULL) {
bool is_default;
- string item("database_file");
- ConstElementPtr value = config_session_->getValue(is_default, item);
+ string use_item("use_memory_datasrc");
+ ConstElementPtr use_value = config_session_->getValue(is_default, use_item);
+ use_memory_datasrc_ = use_value->boolValue();
+
+ string db_item("database_file");
+ ConstElementPtr db_value = config_session_->getValue(is_default, db_item);
ElementPtr final = Element::createMap();
// If the value is the default, and we are running from
@@ -497,13 +523,13 @@
// but for that we need offline access to config, so for
// now this is a decent solution)
if (is_default && getenv("B10_FROM_BUILD")) {
- value = Element::create(string(getenv("B10_FROM_BUILD")) +
+ db_value = Element::create(string(getenv("B10_FROM_BUILD")) +
"/bind10_zones.sqlite3");
}
- final->set(item, value);
+ final->set(db_item, db_value);
config = final;
- db_file_ = value->stringValue();
+ db_file_ = db_value->stringValue();
} else {
return (answer);
}
@@ -535,7 +561,7 @@
try {
// the ModuleCCSession has already checked if we have
// the correct ElementPtr type as specified in our .spec file
- return (impl_->setDbFile(new_config));
+ return (impl_->setConfig(new_config));
} catch (const isc::Exception& error) {
if (impl_->verbose_mode_) {
cerr << "[b10-auth] error: " << error.what() << endl;
Modified: branches/trac439/src/bin/auth/auth_srv.h
==============================================================================
--- branches/trac439/src/bin/auth/auth_srv.h (original)
+++ branches/trac439/src/bin/auth/auth_srv.h Tue Dec 21 11:19:56 2010
@@ -37,6 +37,7 @@
namespace asio_link {
class IOMessage;
}
+
/// \brief The implementation class for the \c AuthSrv class using the pimpl
/// idiom.
Modified: branches/trac439/src/bin/auth/benchmarks/Makefile.am
==============================================================================
--- branches/trac439/src/bin/auth/benchmarks/Makefile.am (original)
+++ branches/trac439/src/bin/auth/benchmarks/Makefile.am Tue Dec 21 11:19:56 2010
@@ -8,6 +8,7 @@
noinst_PROGRAMS = query_bench
query_bench_SOURCES = query_bench.cc
+query_bench_SOURCES += ../query.h ../query.cc
query_bench_SOURCES += ../auth_srv.h ../auth_srv.cc
query_bench_LDADD = $(top_builddir)/src/lib/dns/libdns++.la
Modified: branches/trac439/src/bin/auth/benchmarks/query_bench.cc
==============================================================================
--- branches/trac439/src/bin/auth/benchmarks/query_bench.cc (original)
+++ branches/trac439/src/bin/auth/benchmarks/query_bench.cc Tue Dec 21 11:19:56 2010
@@ -34,11 +34,13 @@
#include <xfr/xfrout_client.h>
#include <auth/auth_srv.h>
+#include <auth/query.h>
#include <auth/asio_link.h>
using namespace std;
using namespace isc;
using namespace isc::data;
+using namespace isc::auth;
using namespace isc::dns;
using namespace isc::xfr;
using namespace isc::bench;
Modified: branches/trac439/src/bin/auth/query.cc
==============================================================================
--- branches/trac439/src/bin/auth/query.cc (original)
+++ branches/trac439/src/bin/auth/query.cc Tue Dec 21 11:19:56 2010
@@ -14,7 +14,6 @@
#include <dns/message.h>
#include <dns/rcode.h>
-#include <iostream>
#include <datasrc/memory_datasrc.h>
@@ -22,7 +21,6 @@
using namespace isc::dns;
using namespace isc::datasrc;
-using namespace std;
namespace isc {
namespace auth {
@@ -69,7 +67,7 @@
case Zone::SUCCESS:
impl_->response_.setRcode(Rcode::NOERROR());
impl_->response_.addRRset(Message::SECTION_ANSWER,
- boost::const_pointer_cast<RRset>(db_result.rrset));
+ boost::const_pointer_cast<RRset>(db_result.rrset));
// fill in authority and addtional sections.
break;
case Zone::DELEGATION:
More information about the bind10-changes
mailing list