diff options
author | Jerry <jerry.zzpku@gmail.com> | 2010-12-21 12:19:56 +0100 |
---|---|---|
committer | Jerry <jerry.zzpku@gmail.com> | 2010-12-21 12:19:56 +0100 |
commit | faebfc883f8886ba7d64760c2e0d3ed2645692bf (patch) | |
tree | 80b7c2d96015b8ae26822c16dc77339965e0ea95 /src | |
parent | * Take MemoryDataSrc (instead of a zone table). (diff) | |
download | kea-faebfc883f8886ba7d64760c2e0d3ed2645692bf.tar.xz kea-faebfc883f8886ba7d64760c2e0d3ed2645692bf.zip |
update AuthSrvImpl::processNormalQuery()
git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac439@3929 e5f2f494-b856-4b98-b285-d166d9295462
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/auth/Makefile.am | 6 | ||||
-rw-r--r-- | src/bin/auth/auth.spec.pre.in | 5 | ||||
-rw-r--r-- | src/bin/auth/auth_srv.cc | 50 | ||||
-rw-r--r-- | src/bin/auth/auth_srv.h | 1 | ||||
-rw-r--r-- | src/bin/auth/benchmarks/Makefile.am | 1 | ||||
-rw-r--r-- | src/bin/auth/benchmarks/query_bench.cc | 2 | ||||
-rw-r--r-- | src/bin/auth/query.cc | 4 |
7 files changed, 51 insertions, 18 deletions
diff --git a/src/bin/auth/Makefile.am b/src/bin/auth/Makefile.am index 2dbd910360..b056d4feaf 100644 --- a/src/bin/auth/Makefile.am +++ b/src/bin/auth/Makefile.am @@ -53,10 +53,10 @@ libasio_link_a_CXXFLAGS += -Wno-error 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 diff --git a/src/bin/auth/auth.spec.pre.in b/src/bin/auth/auth.spec.pre.in index b74fe478fc..88d8a1ca2f 100644 --- a/src/bin/auth/auth.spec.pre.in +++ b/src/bin/auth/auth.spec.pre.in @@ -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, diff --git a/src/bin/auth/auth_srv.cc b/src/bin/auth/auth_srv.cc index 088a1a850d..88558f5b78 100644 --- a/src/bin/auth/auth_srv.cc +++ b/src/bin/auth/auth_srv.cc @@ -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; 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 @@ private: 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 @@ public: /// 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 @@ AuthSrvImpl::processNormalQuery(const IOMessage& io_message, Message& message, } 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 @@ AuthSrvImpl::processNotify(const IOMessage& io_message, Message& message, } 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 @@ AuthSrvImpl::setDbFile(ConstElementPtr config) { // 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 @@ AuthSrv::updateConfig(ConstElementPtr new_config) { 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; diff --git a/src/bin/auth/auth_srv.h b/src/bin/auth/auth_srv.h index b770aece13..4fdc68bedc 100644 --- a/src/bin/auth/auth_srv.h +++ b/src/bin/auth/auth_srv.h @@ -38,6 +38,7 @@ namespace asio_link { class IOMessage; } + /// \brief The implementation class for the \c AuthSrv class using the pimpl /// idiom. class AuthSrvImpl; diff --git a/src/bin/auth/benchmarks/Makefile.am b/src/bin/auth/benchmarks/Makefile.am index e82fa9785d..4f8b5c019f 100644 --- a/src/bin/auth/benchmarks/Makefile.am +++ b/src/bin/auth/benchmarks/Makefile.am @@ -8,6 +8,7 @@ CLEANFILES = *.gcno *.gcda 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 diff --git a/src/bin/auth/benchmarks/query_bench.cc b/src/bin/auth/benchmarks/query_bench.cc index 67c4994bc8..2b2c06027f 100644 --- a/src/bin/auth/benchmarks/query_bench.cc +++ b/src/bin/auth/benchmarks/query_bench.cc @@ -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; diff --git a/src/bin/auth/query.cc b/src/bin/auth/query.cc index eb819098ad..ab67e3f909 100644 --- a/src/bin/auth/query.cc +++ b/src/bin/auth/query.cc @@ -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 @@ Query::process() const { 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: |