BIND 10 trac1976-cont-2, updated. 16f8257f2564999f32cfef6cf87640e0275c5f92 [1976] Support for reloading master files
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu Jul 5 15:08:03 UTC 2012
The branch, trac1976-cont-2 has been updated
via 16f8257f2564999f32cfef6cf87640e0275c5f92 (commit)
from 899ef652280b56e0974fd78c5f0b160c538ae952 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 16f8257f2564999f32cfef6cf87640e0275c5f92
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Thu Jul 5 17:07:40 2012 +0200
[1976] Support for reloading master files
They are special-cased on loading and they need to be special-cased on
reloading too.
-----------------------------------------------------------------------
Summary of changes:
src/lib/datasrc/client_list.cc | 29 ++++++++++++----------
src/lib/datasrc/tests/client_list_unittest.cc | 32 +++++++++++++++++++++++++
2 files changed, 49 insertions(+), 12 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/client_list.cc b/src/lib/datasrc/client_list.cc
index d1ff8de..bdb481e 100644
--- a/src/lib/datasrc/client_list.cc
+++ b/src/lib/datasrc/client_list.cc
@@ -280,19 +280,24 @@ ConfigurableClientList::reload(const Name& name) {
return (ZONE_NOT_CACHED);
}
DataSourceClient* client(info->data_src_client_);
- if (!client) {
- isc_throw(isc::NotImplemented,
- "Reloading of master files not implemented yet. "
- "Next commit or so.");
- }
- // Now do the final reload. If it does not exist in client,
- // DataSourceError is thrown, which is exactly the result what we
- // want, so no need to handle it.
- ZoneIteratorPtr iterator(client->getIterator(name));
- if (!iterator) {
- isc_throw(isc::Unexpected, "Null iterator from " << name);
+ if (client) {
+ // Now do the final reload. If it does not exist in client,
+ // DataSourceError is thrown, which is exactly the result what we
+ // want, so no need to handle it.
+ ZoneIteratorPtr iterator(client->getIterator(name));
+ if (!iterator) {
+ isc_throw(isc::Unexpected, "Null iterator from " << name);
+ }
+ finder->load(*iterator);
+ } else {
+ // The MasterFiles special case
+ const string filename(finder->getFileName());
+ if (filename.empty()) {
+ isc_throw(isc::Unexpected, "Confused about missing both filename "
+ "and data source");
+ }
+ finder->load(filename);
}
- finder->load(*iterator);
return (ZONE_RELOADED);
}
diff --git a/src/lib/datasrc/tests/client_list_unittest.cc b/src/lib/datasrc/tests/client_list_unittest.cc
index 9999297..0bfc6cb 100644
--- a/src/lib/datasrc/tests/client_list_unittest.cc
+++ b/src/lib/datasrc/tests/client_list_unittest.cc
@@ -878,4 +878,36 @@ TEST_F(ListTest, reloadNullIterator) {
list_->find(name).finder_->find(name, RRType::SOA())->code);
}
+// Test we can reload the master files too (special-cased)
+TEST_F(ListTest, reloadMasterFile) {
+ const ConstElementPtr elem(Element::fromJSON("["
+ "{"
+ " \"type\": \"MasterFiles\","
+ " \"cache-enable\": true,"
+ " \"params\": {"
+ " \".\": \"" TEST_DATA_DIR "/root.zone\""
+ " }"
+ "}]"));
+ list_->configure(elem, true);
+ // Add an element there so it differs from the one in file.
+ EXPECT_EQ(ZoneFinder::NXDOMAIN,
+ list_->find(Name(".")).finder_->find(Name("nosuchdomain"),
+ RRType::TXT())->code);
+ RRsetPtr txt(new RRset(Name("nosuchdomain"), RRClass::IN(), RRType::TXT(),
+ RRTTL(3600)));
+ txt->addRdata(rdata::generic::TXT("test"));
+ dynamic_pointer_cast<InMemoryZoneFinder>(list_->find(Name(".")).finder_)->
+ add(txt);
+ // It is here now.
+ EXPECT_EQ(ZoneFinder::SUCCESS,
+ list_->find(Name(".")).finder_->find(Name("nosuchdomain"),
+ RRType::TXT())->code);
+ // Do the reload.
+ EXPECT_EQ(ConfigurableClientList::ZONE_RELOADED, list_->reload(Name(".")));
+ // And our TXT record disappeared again, as it is not in the file.
+ EXPECT_EQ(ZoneFinder::NXDOMAIN,
+ list_->find(Name(".")).finder_->find(Name("nosuchdomain"),
+ RRType::TXT())->code);
+}
+
}
More information about the bind10-changes
mailing list