BIND 10 master, updated. 41538b7ce9d6ab4131b572b79d84292884cf4a11 Merge branch 'master' into trac2206

BIND 10 source code commits bind10-changes at lists.isc.org
Thu Oct 4 09:07:30 UTC 2012


The branch, master has been updated
       via  41538b7ce9d6ab4131b572b79d84292884cf4a11 (commit)
       via  78dfd7dcd6d76cb75d288a3887e8b099c12f3080 (commit)
       via  47c013b000db7235e1ab798eadebc3b42984b06e (commit)
       via  3d68f767731a682d4a80e9ba74d953502c2ada7d (commit)
       via  37fd8a72b131d5de9a6fbe612d3dc3d19bafdf83 (commit)
       via  1fb24f540ade83926d311316e77e1a6c8bef8432 (commit)
       via  c4c3946bad5bf1e9be0f375ac1029e1f95e94d94 (commit)
       via  5c975417200358c916a62415caf51a1a73e0d470 (commit)
       via  538a160ef48f7dbe927f75cafc335e470a82db33 (commit)
       via  e45115237b2c8c12f0c2fd3c62ae0aff01248cc9 (commit)
       via  a072ee8db55261a67dc7041c7c17d0536f8def0b (commit)
       via  473e340929d0869bf71d972e1a1843dc81b0fbfa (commit)
       via  94656c03d42d0339c79d10be8ccedaea6da55028 (commit)
       via  a6748eee324ebb4cf4ba99aa225df51d71458c81 (commit)
       via  5acf0ff36e8503de33ce04fe16e279ec6ee871f1 (commit)
       via  14680316801f9274e5b4d099a4dfbf63d7cb110b (commit)
       via  d25bb8d27cf235603cb8a1d789066b2aa993eccd (commit)
       via  f2b62e24805e97f66aeac4f9ab3db2d9778c9314 (commit)
       via  1ab6aafab6660d60a5f2e7cf7125d59d5807f2e5 (commit)
      from  f802291f6461f3fa7e13fcf3364bb39b4be42c06 (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 41538b7ce9d6ab4131b572b79d84292884cf4a11
Merge: 78dfd7d f802291
Author: Mukund Sivaraman <muks at isc.org>
Date:   Thu Oct 4 13:43:53 2012 +0530

    Merge branch 'master' into trac2206

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

Summary of changes:
 src/lib/datasrc/memory/Makefile.am                 |    2 +
 .../memory/zone_table_segment.cc}                  |   44 ++++----
 src/lib/datasrc/memory/zone_table_segment.h        |  110 ++++++++++++++++++++
 .../memory/zone_table_segment_local.cc}            |   47 ++++-----
 src/lib/datasrc/memory/zone_table_segment_local.h  |   66 ++++++++++++
 src/lib/datasrc/tests/memory/Makefile.am           |    1 +
 .../tests/memory/zone_table_segment_unittest.cc    |   83 +++++++++++++++
 7 files changed, 304 insertions(+), 49 deletions(-)
 copy src/lib/{python/isc/datasrc/configurableclientlist_python.h => datasrc/memory/zone_table_segment.cc} (60%)
 create mode 100644 src/lib/datasrc/memory/zone_table_segment.h
 copy src/lib/{python/isc/datasrc/configurableclientlist_python.h => datasrc/memory/zone_table_segment_local.cc} (60%)
 create mode 100644 src/lib/datasrc/memory/zone_table_segment_local.h
 create mode 100644 src/lib/datasrc/tests/memory/zone_table_segment_unittest.cc

-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/memory/Makefile.am b/src/lib/datasrc/memory/Makefile.am
index 3bdec0d..743caa2 100644
--- a/src/lib/datasrc/memory/Makefile.am
+++ b/src/lib/datasrc/memory/Makefile.am
@@ -20,6 +20,8 @@ libdatasrc_memory_la_SOURCES += memory_client.h memory_client.cc
 libdatasrc_memory_la_SOURCES += logger.h logger.cc
 libdatasrc_memory_la_SOURCES += zone_table.h zone_table.cc
 libdatasrc_memory_la_SOURCES += zone_finder.h zone_finder.cc
+libdatasrc_memory_la_SOURCES += zone_table_segment.h zone_table_segment.cc
+libdatasrc_memory_la_SOURCES += zone_table_segment_local.h zone_table_segment_local.cc
 nodist_libdatasrc_memory_la_SOURCES = memory_messages.h memory_messages.cc
 
 EXTRA_DIST  = rdata_serialization_priv.cc
diff --git a/src/lib/datasrc/memory/zone_table_segment.cc b/src/lib/datasrc/memory/zone_table_segment.cc
new file mode 100644
index 0000000..7a80e3c
--- /dev/null
+++ b/src/lib/datasrc/memory/zone_table_segment.cc
@@ -0,0 +1,38 @@
+// Copyright (C) 2012  Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#include <datasrc/memory/zone_table_segment.h>
+#include <datasrc/memory/zone_table_segment_local.h>
+
+namespace isc {
+namespace datasrc {
+namespace memory {
+
+ZoneTableSegment*
+ZoneTableSegment::create(const isc::data::Element&) {
+    /// FIXME: For now, we always return ZoneTableSegmentLocal. This
+    /// should be updated eventually to parse the passed Element
+    /// argument and construct a corresponding ZoneTableSegment
+    /// implementation.
+    return (new ZoneTableSegmentLocal);
+}
+
+void
+ZoneTableSegment::destroy(ZoneTableSegment *segment) {
+    delete segment;
+}
+
+} // namespace memory
+} // namespace datasrc
+} // namespace isc
diff --git a/src/lib/datasrc/memory/zone_table_segment.h b/src/lib/datasrc/memory/zone_table_segment.h
new file mode 100644
index 0000000..7fd1310
--- /dev/null
+++ b/src/lib/datasrc/memory/zone_table_segment.h
@@ -0,0 +1,110 @@
+// Copyright (C) 2012  Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#ifndef __ZONE_TABLE_SEGMENT_H__
+#define __ZONE_TABLE_SEGMENT_H__
+
+#include <datasrc/memory/zone_table.h>
+#include <cc/data.h>
+#include <util/memory_segment.h>
+
+#include <boost/interprocess/offset_ptr.hpp>
+
+#include <stdlib.h>
+
+namespace isc {
+namespace datasrc {
+namespace memory {
+
+/// \brief Memory-management independent entry point that contains a
+/// pointer to a zone table in memory.
+///
+/// An instance of this type lives inside a ZoneTableSegment
+/// implementation. It contains an offset pointer to the zone table (a
+/// map from domain names to zone locators) in memory.
+struct ZoneTableHeader {
+public:
+    /// \brief Returns a pointer to the underlying zone table.
+    ZoneTable* getTable() {
+        return (table.get());
+    }
+
+    /// \brief const version of \c getTable().
+    const ZoneTable* getTable() const {
+        return (table.get());
+    }
+
+private:
+    boost::interprocess::offset_ptr<ZoneTable> table;
+};
+
+/// \brief Manages a ZoneTableHeader, an entry point into a table of
+/// zones
+///
+/// This class specifies an interface for derived implementations which
+/// return a pointer to an object of type ZoneTableHeader, an entry
+/// point into a table of zones regardless of the underlying memory
+/// management implementation. Derived classes would implement the
+/// interface for specific memory-implementation behavior.
+class ZoneTableSegment {
+protected:
+    /// \brief Protected constructor
+    ///
+    /// An instance implementing this interface is expected to be
+    /// created by the factory method (\c create()), so this constructor
+    /// is protected.
+    ZoneTableSegment()
+    {}
+public:
+    /// \brief Destructor
+    virtual ~ZoneTableSegment() {}
+
+    /// \brief Return the ZoneTableHeader for the zone table segment.
+    virtual ZoneTableHeader& getHeader() = 0;
+
+    /// \brief const version of \c getHeader().
+    virtual const ZoneTableHeader& getHeader() const = 0;
+
+    /// \brief Return the MemorySegment for the zone table segment.
+    virtual isc::util::MemorySegment& getMemorySegment() = 0;
+
+    /// \brief Create an instance depending on the memory segment model
+    ///
+    /// This is a factory method to create a derived ZoneTableSegment
+    /// object based on the \c config passed. The method returns a
+    /// dynamically-allocated object. The caller is responsible for
+    /// destroying it with \c ZoneTableSegment::destroy().
+    ///
+    /// FIXME: For now, we always return ZoneTableSegmentLocal
+    /// regardless of the passed \c config.
+    ///
+    /// \param config The configuration based on which a derived object
+    ///               is returned.
+    /// \return Returns a ZoneTableSegment object
+    static ZoneTableSegment* create(const isc::data::Element& config);
+
+    /// \brief Destroy a ZoneTableSegment
+    ///
+    /// This method destroys the passed ZoneTableSegment. It must be
+    /// passed a segment previously created by \c ZoneTableSegment::create().
+    ///
+    /// \param segment The segment to destroy.
+    static void destroy(ZoneTableSegment* segment);
+};
+
+} // namespace memory
+} // namespace datasrc
+} // namespace isc
+
+#endif // __ZONE_TABLE_SEGMENT_H__
diff --git a/src/lib/datasrc/memory/zone_table_segment_local.cc b/src/lib/datasrc/memory/zone_table_segment_local.cc
new file mode 100644
index 0000000..589c9af
--- /dev/null
+++ b/src/lib/datasrc/memory/zone_table_segment_local.cc
@@ -0,0 +1,43 @@
+// Copyright (C) 2012  Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#include <datasrc/memory/zone_table_segment_local.h>
+
+using namespace isc::util;
+
+namespace isc {
+namespace datasrc {
+namespace memory {
+
+// After more methods' definitions are added here, it would be a good
+// idea to move getHeader() and getMemorySegment() definitions to the
+// header file.
+ZoneTableHeader&
+ZoneTableSegmentLocal::getHeader() {
+     return (header_);
+}
+
+const ZoneTableHeader&
+ZoneTableSegmentLocal::getHeader() const {
+     return (header_);
+}
+
+MemorySegment&
+ZoneTableSegmentLocal::getMemorySegment() {
+     return (mem_sgmt_);
+}
+
+} // namespace memory
+} // namespace datasrc
+} // namespace isc
diff --git a/src/lib/datasrc/memory/zone_table_segment_local.h b/src/lib/datasrc/memory/zone_table_segment_local.h
new file mode 100644
index 0000000..de776a9
--- /dev/null
+++ b/src/lib/datasrc/memory/zone_table_segment_local.h
@@ -0,0 +1,66 @@
+// Copyright (C) 2012  Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#ifndef __ZONE_TABLE_SEGMENT_LOCAL_H__
+#define __ZONE_TABLE_SEGMENT_LOCAL_H__
+
+#include <datasrc/memory/zone_table_segment.h>
+#include <util/memory_segment_local.h>
+
+namespace isc {
+namespace datasrc {
+namespace memory {
+
+/// \brief Local implementation of ZoneTableSegment class
+///
+/// This class specifies a concrete implementation for a
+/// MemorySegmentLocal based ZoneTableSegment. Please see the
+/// ZoneTableSegment class documentation for usage.
+class ZoneTableSegmentLocal : public ZoneTableSegment {
+    // This is so that ZoneTableSegmentLocal can be instantiated from
+    // ZoneTableSegment::create().
+    friend class ZoneTableSegment;
+protected:
+    /// \brief Protected constructor
+    ///
+    /// Instances are expected to be created by the factory method
+    /// (\c ZoneTableSegment::create()), so this constructor is
+    /// protected.
+    ZoneTableSegmentLocal()
+    {}
+public:
+    /// \brief Destructor
+    virtual ~ZoneTableSegmentLocal() {}
+
+    /// \brief Return the ZoneTableHeader for the local zone table
+    /// segment implementation.
+    virtual ZoneTableHeader& getHeader();
+
+    /// \brief const version of \c getHeader().
+    virtual const ZoneTableHeader& getHeader() const;
+
+    /// \brief Return the MemorySegment for the local zone table segment
+    /// implementation (a MemorySegmentLocal instance).
+    virtual isc::util::MemorySegment& getMemorySegment();
+
+private:
+    ZoneTableHeader header_;
+    isc::util::MemorySegmentLocal mem_sgmt_;
+};
+
+} // namespace memory
+} // namespace datasrc
+} // namespace isc
+
+#endif // __ZONE_TABLE_SEGMENT_LOCAL_H__
diff --git a/src/lib/datasrc/tests/memory/Makefile.am b/src/lib/datasrc/tests/memory/Makefile.am
index 00d5594..1cde4f5 100644
--- a/src/lib/datasrc/tests/memory/Makefile.am
+++ b/src/lib/datasrc/tests/memory/Makefile.am
@@ -32,6 +32,7 @@ run_unittests_SOURCES += ../../tests/faked_nsec3.h ../../tests/faked_nsec3.cc
 run_unittests_SOURCES += memory_segment_test.h
 run_unittests_SOURCES += segment_object_holder_unittest.cc
 run_unittests_SOURCES += memory_client_unittest.cc
+run_unittests_SOURCES += zone_table_segment_unittest.cc
 
 run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
 run_unittests_LDFLAGS  = $(AM_LDFLAGS)  $(GTEST_LDFLAGS)
diff --git a/src/lib/datasrc/tests/memory/zone_table_segment_unittest.cc b/src/lib/datasrc/tests/memory/zone_table_segment_unittest.cc
new file mode 100644
index 0000000..6bdd737
--- /dev/null
+++ b/src/lib/datasrc/tests/memory/zone_table_segment_unittest.cc
@@ -0,0 +1,83 @@
+// Copyright (C) 2012  Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#include <datasrc/memory/zone_table_segment.h>
+#include <gtest/gtest.h>
+
+using namespace isc::datasrc::memory;
+using namespace isc::data;
+using namespace isc::util;
+using namespace std;
+
+namespace {
+
+class ZoneTableSegmentTest : public ::testing::Test {
+protected:
+    ZoneTableSegmentTest() :
+        config_(Element::fromJSON("{}")),
+        segment_(ZoneTableSegment::create((*config_.get())))
+    {}
+
+    ~ZoneTableSegmentTest() {
+        if (segment_ != NULL) {
+            ZoneTableSegment::destroy(segment_);
+        }
+    }
+
+    void TearDown() {
+        // Catch any future leaks here.
+        const MemorySegment& mem_sgmt = segment_->getMemorySegment();
+        EXPECT_TRUE(mem_sgmt.allMemoryDeallocated());
+
+        ZoneTableSegment::destroy(segment_);
+        segment_ = NULL;
+    }
+
+    const ElementPtr config_;
+    ZoneTableSegment* segment_;
+};
+
+
+TEST_F(ZoneTableSegmentTest, create) {
+    // By default, a local zone table segment is created.
+    EXPECT_NE(static_cast<void*>(NULL), segment_);
+}
+
+// Helper function to check const and non-const methods.
+template <typename TS, typename TH, typename TT>
+void
+testGetHeader(ZoneTableSegment* segment) {
+    TH& header = static_cast<TS*>(segment)->getHeader();
+
+    // The zone table is unset.
+    TT* table = header.getTable();
+    EXPECT_EQ(static_cast<void*>(NULL), table);
+}
+
+TEST_F(ZoneTableSegmentTest, getHeader) {
+    // non-const version.
+    testGetHeader<ZoneTableSegment, ZoneTableHeader, ZoneTable>(segment_);
+
+    // const version.
+    testGetHeader<const ZoneTableSegment, const ZoneTableHeader,
+                  const ZoneTable>(segment_);
+}
+
+TEST_F(ZoneTableSegmentTest, getMemorySegment) {
+    // This doesn't do anything fun except test the API.
+    MemorySegment& mem_sgmt = segment_->getMemorySegment();
+    EXPECT_TRUE(mem_sgmt.allMemoryDeallocated());
+}
+
+} // anonymous namespace



More information about the bind10-changes mailing list