boost::shared_ptr<ConfigurableClientList> getClientList(const RRClass&
rrclass)
{
+ // TODO: Debug-build only check
+ if (!mutex_.locked()) {
+ isc_throw(isc::Unexpected, "Not locked!");
+ }
const std::map<RRClass, boost::shared_ptr<ConfigurableClientList> >::
const_iterator it(client_lists_.find(rrclass));
if (it == client_lists_.end()) {
void
AuthSrv::setClientList(const RRClass& rrclass,
const boost::shared_ptr<ConfigurableClientList>& list) {
+ // TODO: Debug-build only check
+ if (!impl_->mutex_.locked()) {
+ isc_throw(isc::Unexpected, "Not locked");
+ }
+
if (list) {
impl_->client_lists_[rrclass] = list;
} else {
vector<RRClass>
AuthSrv::getClientListClasses() const {
+ // TODO: Debug-build only check
+ if (!impl_->mutex_.locked()) {
+ isc_throw(isc::Unexpected, "Not locked");
+ }
+
vector<RRClass> result;
for (std::map<RRClass, boost::shared_ptr<ConfigurableClientList> >::
const_iterator it(impl_->client_lists_.begin());
{
// Set real inmem client to proxy
updateInMemory(&server, "example.", CONFIG_INMEMORY_EXAMPLE);
- boost::shared_ptr<isc::datasrc::ConfigurableClientList>
- list(new FakeList(server.getClientList(RRClass::IN()), THROW_NEVER,
- false));
- server.setClientList(RRClass::IN(), list);
+ {
+ isc::util::thread::Mutex::Locker locker(server.getClientListMutex());
+ boost::shared_ptr<isc::datasrc::ConfigurableClientList>
+ list(new FakeList(server.getClientList(RRClass::IN()), THROW_NEVER,
+ false));
+ server.setClientList(RRClass::IN(), list);
+ }
createDataFromFile("nsec3query_nodnssec_fromWire.wire");
server.processMessage(*io_message, *parse_message, *response_obuffer,
{
updateInMemory(server, "example.", CONFIG_INMEMORY_EXAMPLE);
+ isc::util::thread::Mutex::Locker locker(server->getClientListMutex());
boost::shared_ptr<isc::datasrc::ConfigurableClientList>
list(new FakeList(server->getClientList(RRClass::IN()), throw_when,
isc_exception, rrset));
// Check the client list accessors
TEST_F(AuthSrvTest, clientList) {
+ // We need to lock the mutex to make the (get|set)ClientList happy.
+ // There's a debug-build only check in them to make sure everything
+ // locks them and we call them directly here.
+ isc::util::thread::Mutex::Locker locker(server.getClientListMutex());
// The lists don't exist. Therefore, the list of RRClasses is empty.
// We also have no IN list.
EXPECT_TRUE(server.getClientListClasses().empty());
// zones, and checks the zones are correctly loaded.
void
zoneChecks(AuthSrv& server) {
+ isc::util::thread::Mutex::Locker locker(server.getClientListMutex());
EXPECT_EQ(ZoneFinder::SUCCESS, server.getClientList(RRClass::IN())->
find(Name("ns.test1.example")).finder_->
find(Name("ns.test1.example"), RRType::A())->code);
void
newZoneChecks(AuthSrv& server) {
+ isc::util::thread::Mutex::Locker locker(server.getClientListMutex());
EXPECT_EQ(ZoneFinder::SUCCESS, server.getClientList(RRClass::IN())->
find(Name("ns.test1.example")).finder_->
find(Name("ns.test1.example"), RRType::A())->code);
"}]}"));
DataSourceConfigurator::testReconfigure(&server_, config);
- // Check that the A record at www.example.org does not exist
- EXPECT_EQ(ZoneFinder::NXDOMAIN, server_.getClientList(RRClass::IN())->
- find(Name("example.org")).finder_->
- find(Name("www.example.org"), RRType::A())->code);
-
- // Add the record to the underlying sqlite database, by loading
- // it as a separate datasource, and updating it
- ConstElementPtr sql_cfg = Element::fromJSON("{ \"type\": \"sqlite3\","
- "\"database_file\": \""
- + test_db + "\"}");
- DataSourceClientContainer sql_ds("sqlite3", sql_cfg);
- ZoneUpdaterPtr sql_updater =
- sql_ds.getInstance().getUpdater(Name("example.org"), false);
- RRsetPtr rrset(new RRset(Name("www.example.org."), RRClass::IN(),
- RRType::A(), RRTTL(60)));
- rrset->addRdata(rdata::createRdata(rrset->getType(),
- rrset->getClass(),
- "192.0.2.1"));
- sql_updater->addRRset(*rrset);
- sql_updater->commit();
-
- EXPECT_EQ(ZoneFinder::NXDOMAIN, server_.getClientList(RRClass::IN())->
- find(Name("example.org")).finder_->
- find(Name("www.example.org"), RRType::A())->code);
+ {
+ isc::util::thread::Mutex::Locker locker(server_.getClientListMutex());
+ // Check that the A record at www.example.org does not exist
+ EXPECT_EQ(ZoneFinder::NXDOMAIN, server_.getClientList(RRClass::IN())->
+ find(Name("example.org")).finder_->
+ find(Name("www.example.org"), RRType::A())->code);
+
+ // Add the record to the underlying sqlite database, by loading
+ // it as a separate datasource, and updating it
+ ConstElementPtr sql_cfg = Element::fromJSON("{ \"type\": \"sqlite3\","
+ "\"database_file\": \""
+ + test_db + "\"}");
+ DataSourceClientContainer sql_ds("sqlite3", sql_cfg);
+ ZoneUpdaterPtr sql_updater =
+ sql_ds.getInstance().getUpdater(Name("example.org"), false);
+ RRsetPtr rrset(new RRset(Name("www.example.org."), RRClass::IN(),
+ RRType::A(), RRTTL(60)));
+ rrset->addRdata(rdata::createRdata(rrset->getType(),
+ rrset->getClass(),
+ "192.0.2.1"));
+ sql_updater->addRRset(*rrset);
+ sql_updater->commit();
+
+ EXPECT_EQ(ZoneFinder::NXDOMAIN, server_.getClientList(RRClass::IN())->
+ find(Name("example.org")).finder_->
+ find(Name("www.example.org"), RRType::A())->code);
+ }
// Now send the command to reload it
result_ = execAuthServerCommand(server_, "loadzone",
"{\"origin\": \"example.org\"}"));
checkAnswer(0, "Successful load");
- // And now it should be present too.
- EXPECT_EQ(ZoneFinder::SUCCESS, server_.getClientList(RRClass::IN())->
- find(Name("example.org")).finder_->
- find(Name("www.example.org"), RRType::A())->code);
+ {
+ isc::util::thread::Mutex::Locker locker(server_.getClientListMutex());
+ // And now it should be present too.
+ EXPECT_EQ(ZoneFinder::SUCCESS, server_.getClientList(RRClass::IN())->
+ find(Name("example.org")).finder_->
+ find(Name("www.example.org"), RRType::A())->code);
+ }
// Some error cases. First, the zone has no configuration. (note .com here)
result_ = execAuthServerCommand(server_, "loadzone",
Element::fromJSON("{\"origin\": \"example.com\"}"));
checkAnswer(1, "example.com");
- // The previous zone is not hurt in any way
- EXPECT_EQ(ZoneFinder::SUCCESS, server_.getClientList(RRClass::IN())->
- find(Name("example.org")).finder_->
- find(Name("example.org"), RRType::SOA())->code);
+ {
+ isc::util::thread::Mutex::Locker locker(server_.getClientListMutex());
+ // The previous zone is not hurt in any way
+ EXPECT_EQ(ZoneFinder::SUCCESS, server_.getClientList(RRClass::IN())->
+ find(Name("example.org")).finder_->
+ find(Name("example.org"), RRType::SOA())->code);
+ }
const ConstElementPtr config2(Element::fromJSON("{"
"\"IN\": [{"
Element::fromJSON("{\"origin\": \"example.com\"}"));
checkAnswer(1, "Unreadable");
+ isc::util::thread::Mutex::Locker locker(server_.getClientListMutex());
// The previous zone is not hurt in any way
EXPECT_EQ(ZoneFinder::SUCCESS, server_.getClientList(RRClass::IN())->
find(Name("example.org")).finder_->