Commit faebfc88 authored by Jerry's avatar Jerry
Browse files

update AuthSrvImpl::processNormalQuery()



git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac439@3929 e5f2f494-b856-4b98-b285-d166d9295462
parent d308d150
......@@ -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
......
......@@ -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,
......
......@@ -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;
......
......@@ -38,6 +38,7 @@ namespace asio_link {
class IOMessage;
}
/// \brief The implementation class for the \c AuthSrv class using the pimpl
/// idiom.
class AuthSrvImpl;
......
......@@ -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
......
......@@ -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;
......
......@@ -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:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment