BIND 10 trac1793, updated. 52707b19511b499401a61b42eb3a03207f79b0c6 [1793] Minor editorial fixes

BIND 10 source code commits bind10-changes at lists.isc.org
Wed Apr 18 08:43:10 UTC 2012


The branch, trac1793 has been updated
       via  52707b19511b499401a61b42eb3a03207f79b0c6 (commit)
       via  f782145ec0759ef8e595c87d4baf15de89624ea7 (commit)
      from  4deb49cf84c399a0ca1a84fef1cd0dee4ca4d5d5 (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 52707b19511b499401a61b42eb3a03207f79b0c6
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Wed Apr 18 10:27:45 2012 +0200

    [1793] Minor editorial fixes

commit f782145ec0759ef8e595c87d4baf15de89624ea7
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Wed Apr 18 10:08:42 2012 +0200

    [1793] Split the config lookup out of validate
    
    It is now placed into the getZoneConfig method. This is code cleanup
    only, functionality should not be changed.

-----------------------------------------------------------------------

Summary of changes:
 src/bin/auth/command.cc                |   41 +++++++++++++++++++++----------
 src/bin/auth/tests/command_unittest.cc |    5 ++-
 2 files changed, 31 insertions(+), 15 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/auth/command.cc b/src/bin/auth/command.cc
index 3962436..8feda3b 100644
--- a/src/bin/auth/command.cc
+++ b/src/bin/auth/command.cc
@@ -144,12 +144,21 @@ public:
 // Handle the "loadzone" command.
 class LoadZoneCommand : public AuthCommand {
 public:
+    LoadZoneCommand() :
+        // Just fill in something, these can't be created "without data",
+        // by constructor without parameters. These values will be overwritten
+        // in validate().
+        origin_(Name::ROOT_NAME()),
+        zone_class_(RRClass::IN())
+    { }
     virtual void exec(AuthSrv& server, isc::data::ConstElementPtr args) {
         // parse and validate the args.
         if (!validate(server, args)) {
             return;
         }
 
+        getZoneConfig(server);
+
         // Load a new zone and replace the current zone with the new one.
         // TODO: eventually this should be incremental or done in some way
         // that doesn't block other server operations.
@@ -181,6 +190,10 @@ private:
     // The configuration corresponding to the zone.
     ConstElementPtr zone_config_;
 
+    // Parameters of the zone
+    Name origin_;
+    RRClass zone_class_;
+
     // A helper private method to parse and validate command parameters.
     // On success, it sets 'old_zone_finder' to the zone to be updated.
     // It returns true if everything is okay; and false if the command is
@@ -207,11 +220,11 @@ private:
         }
 
         ConstElementPtr class_elem = args->get("class");
-        const RRClass zone_class = class_elem ?
-            RRClass(class_elem->stringValue()) : RRClass::IN();
+        zone_class_ = class_elem ? RRClass(class_elem->stringValue()) :
+            RRClass::IN();
 
         AuthSrv::InMemoryClientPtr datasrc(server.
-                                           getInMemoryClient(zone_class));
+                                           getInMemoryClient(zone_class_));
         if (datasrc == NULL) {
             isc_throw(AuthCommandError, "Memory data source is disabled");
         }
@@ -220,18 +233,22 @@ private:
         if (!origin_elem) {
             isc_throw(AuthCommandError, "Zone origin is missing");
         }
-        const Name origin(origin_elem->stringValue());
+        origin_ = Name(origin_elem->stringValue());
 
         // Get the current zone
-        const InMemoryClient::FindResult result = datasrc->findZone(origin);
+        const InMemoryClient::FindResult result = datasrc->findZone(origin_);
         if (result.code != result::SUCCESS) {
-            isc_throw(AuthCommandError, "Zone " << origin <<
+            isc_throw(AuthCommandError, "Zone " << origin_ <<
                       " is not found in data source");
         }
 
         old_zone_finder = boost::dynamic_pointer_cast<InMemoryZoneFinder>(
             result.zone_finder);
 
+        return (true);
+    }
+
+    void getZoneConfig(const AuthSrv &server) {
         if (!server.getConfigSession()) {
             // FIXME: This is a hack to make older tests pass. We should
             // update these tests as well sometime and remove this hack.
@@ -241,7 +258,7 @@ private:
             // We provide an empty map, which means no configuration --
             // defaults.
             zone_config_ = ConstElementPtr(new MapElement());
-            return (true);
+            return;
         }
 
         // Find the config corresponding to the zone.
@@ -253,7 +270,7 @@ private:
         // Unfortunately, we need to walk the list to find the correct data
         // source.
         // TODO: Make it named sets. These lists are uncomfortable.
-        for (size_t i(0); i < config->size(); ++ i) {
+        for (size_t i(0); i < config->size(); ++i) {
             // We use the getValue to get defaults as well
             const ConstElementPtr dsrc_config(config->get(i));
             const ConstElementPtr class_config(dsrc_config->get("class"));
@@ -265,7 +282,7 @@ private:
             // anyway and we may want to change the configuration of
             // datasources somehow.
             if (dsrc_config->get("type")->stringValue() == "memory" &&
-                RRClass(class_type) == zone_class) {
+                RRClass(class_type) == zone_class_) {
                 zone_list = dsrc_config->get("zones");
                 break;
             }
@@ -277,9 +294,9 @@ private:
         }
 
         // Now we need to walk the zones and find the correct one.
-        for (size_t i(0); i < zone_list->size(); ++ i) {
+        for (size_t i(0); i < zone_list->size(); ++i) {
             const ConstElementPtr zone_config(zone_list->get(i));
-            if (Name(zone_config->get("origin")->stringValue()) == origin) {
+            if (Name(zone_config->get("origin")->stringValue()) == origin_) {
                 // The origins are the same, so we consider this config to be
                 // for the zone.
                 zone_config_ = zone_config;
@@ -291,8 +308,6 @@ private:
             isc_throw(AuthCommandError,
                       "Corresponding zone configuration was not found");
         }
-
-        return (true);
     }
 };
 
diff --git a/src/bin/auth/tests/command_unittest.cc b/src/bin/auth/tests/command_unittest.cc
index 52f60b3..aa29ba3 100644
--- a/src/bin/auth/tests/command_unittest.cc
+++ b/src/bin/auth/tests/command_unittest.cc
@@ -56,8 +56,6 @@ using namespace isc::auth::unittest;
 
 namespace {
 
-const char* const SPEC_FILE = AUTH_OBJ_DIR "/auth.spec";
-
 class AuthCommandTest : public ::testing::Test {
 protected:
     AuthCommandTest() :
@@ -262,6 +260,8 @@ TEST_F(AuthCommandTest,
 #endif
     )
 {
+    const char* const SPEC_FILE = AUTH_OBJ_DIR "/auth.spec";
+
     // Prepare the database first
     const string test_db = TEST_DATA_BUILDDIR "/auth_test.sqlite3.copied";
     const string bad_db = TEST_DATA_BUILDDIR "/does-not-exist.sqlite3";
@@ -319,6 +319,7 @@ TEST_F(AuthCommandTest,
         Element::fromJSON("{\"origin\": \"example.com\"}"));
     checkAnswer(1);
 
+    // The previous zone is not hurt in any way
     EXPECT_EQ(ZoneFinder::SUCCESS, server_.getInMemoryClient(RRClass::IN())->
               findZone(Name("example.org")).zone_finder->
               find(Name("example.org"), RRType::SOA())->code);



More information about the bind10-changes mailing list