BIND 10 trac1976, updated. 1124a637dfa3b123519bbd0e5e28d3b370c0bf4e [1976] Fix deletions
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu Jun 21 11:37:38 UTC 2012
The branch, trac1976 has been updated
via 1124a637dfa3b123519bbd0e5e28d3b370c0bf4e (commit)
from 59a8af594d8c0a0ea672dece5d10cd995fb4c0c2 (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 1124a637dfa3b123519bbd0e5e28d3b370c0bf4e
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Thu Jun 21 13:34:36 2012 +0200
[1976] Fix deletions
It looks like the configuration is provided as a whole, not a diff only.
At least to the callback.
-----------------------------------------------------------------------
Summary of changes:
src/bin/auth/datasrc_configurator.h | 38 ++++++++++++--------
.../auth/tests/datasrc_configurator_unittest.cc | 30 +++++++++-------
2 files changed, 42 insertions(+), 26 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/auth/datasrc_configurator.h b/src/bin/auth/datasrc_configurator.h
index bd80c78..681d265 100644
--- a/src/bin/auth/datasrc_configurator.h
+++ b/src/bin/auth/datasrc_configurator.h
@@ -21,6 +21,8 @@
#include <config/ccsession.h>
#include <cc/data.h>
+#include <set>
+
/// \brief A class to configure the authoritative server's data source lists
///
/// This will hook into the data_sources module configuration and it will
@@ -115,25 +117,33 @@ public:
isc_throw(isc::InvalidOperation,
"Can't reconfigure while not inited");
}
+ // Get the configuration and current state.
typedef std::map<std::string, isc::data::ConstElementPtr> Map;
const Map& map(config->mapValue());
- for (Map::const_iterator it(map.begin()); it != map.end(); ++ it) {
+ const std::vector<isc::dns::RRClass>
+ activeVector(server_->getClientListClasses());
+ std::set<isc::dns::RRClass> active(activeVector.begin(),
+ activeVector.end());
+ // Go through the configuration and change everything.
+ for (Map::const_iterator it(map.begin()); it != map.end(); ++it) {
isc::dns::RRClass rrclass(it->first);
- if (it->second->getType() == isc::data::Element::null) {
- server_->setClientList(rrclass, ListPtr());
- } else {
- ListPtr list(server_->getClientList(rrclass));
- bool need_set(false);
- if (!list) {
- list.reset(new List);
- need_set = true;
- }
- list->configure(*it->second, true);
- if (need_set) {
- server_->setClientList(rrclass, list);
- }
+ active.erase(rrclass);
+ ListPtr list(server_->getClientList(rrclass));
+ bool need_set(false);
+ if (!list) {
+ list.reset(new List);
+ need_set = true;
+ }
+ list->configure(*it->second, true);
+ if (need_set) {
+ server_->setClientList(rrclass, list);
}
}
+ // Remove the ones that are not in the configuration.
+ for (std::set<isc::dns::RRClass>::iterator it(active.begin());
+ it != active.end(); ++it) {
+ server_->setClientList(*it, ListPtr());
+ }
}
};
diff --git a/src/bin/auth/tests/datasrc_configurator_unittest.cc b/src/bin/auth/tests/datasrc_configurator_unittest.cc
index 55fa1b6..85c413e 100644
--- a/src/bin/auth/tests/datasrc_configurator_unittest.cc
+++ b/src/bin/auth/tests/datasrc_configurator_unittest.cc
@@ -65,6 +65,14 @@ public:
(list ? list->getConf() : "") + "\n";
lists_[rrclass] = list;
}
+ vector<RRClass> getClientListClasses() const {
+ vector<RRClass> result;
+ for (map<RRClass, ListPtr>::const_iterator it(lists_.begin());
+ it != lists_.end(); ++it) {
+ result.push_back(it->first);
+ }
+ return (result);
+ }
protected:
DatasrcConfiguratorTest() :
session(ElementPtr(new ListElement), ElementPtr(new ListElement),
@@ -176,39 +184,37 @@ TEST_F(DatasrcConfiguratorTest, multiple) {
// Check we can add another one later and the old one does not get
// overwritten.
+//
+// It's almost like above, but we initialize first with single-list
+// config.
TEST_F(DatasrcConfiguratorTest, updateAdd) {
- // TODO: Make sure the communication protocol really works on
- // the semi-diff principle here, not by sending everything.
- // (actually, sending everything would work, as per above, two
- // tests, but this test would be wrong).
doInInit();
const ElementPtr
- config(Element::fromJSON("{\"CH\": [{\"type\": \"yyy\"}]}"));
+ config(Element::fromJSON("{\"IN\": [{\"type\": \"yyy\"}], "
+ "\"CH\": [{\"type\": \"xxx\"}]}"));
session.addMessage(createCommand("config_update", config), "data_sources",
"*");
log_ = "";
mccs->checkCommand();
// This one does not set
- EXPECT_EQ("get CH\nset CH yyy\n", log_);
+ EXPECT_EQ("get CH\nset CH xxx\nget IN\n", log_);
// But this should contain the yyy configuration
- EXPECT_EQ("yyy", lists_[RRClass::CH()]->getConf());
- EXPECT_EQ("xxx", lists_[RRClass::IN()]->getConf());
+ EXPECT_EQ("xxx", lists_[RRClass::CH()]->getConf());
+ EXPECT_EQ("yyy", lists_[RRClass::IN()]->getConf());
EXPECT_EQ(2, lists_.size());
}
// We delete a class list in this test.
TEST_F(DatasrcConfiguratorTest, updateDelete) {
- // TODO: Make sure the protocol sends the diff and a delete
- // is done by a null element. Where is a documentation for this?
doInInit();
const ElementPtr
- config(Element::fromJSON("{\"IN\": null}"));
+ config(Element::fromJSON("{}"));
session.addMessage(createCommand("config_update", config), "data_sources",
"*");
log_ = "";
mccs->checkCommand();
- // This one does not set
EXPECT_EQ("set IN \n", log_);
+ EXPECT_FALSE(lists_[RRClass::IN()]);
}
More information about the bind10-changes
mailing list