BIND 10 trac2836, updated. ac01dfd069e66c85409e93b40385a393bb5c5a59 [2836] Conditional code compilation

BIND 10 source code commits bind10-changes at lists.isc.org
Wed May 15 11:27:38 UTC 2013


The branch, trac2836 has been updated
       via  ac01dfd069e66c85409e93b40385a393bb5c5a59 (commit)
       via  61e6c39d6f14c8d06956e92002b53f9448453b4d (commit)
       via  598d81ecdbc43b8e6869ba65c60b1d7b4fb155e3 (commit)
      from  cdb6afba87fa03187512682b8348e65dc5e24a0f (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 ac01dfd069e66c85409e93b40385a393bb5c5a59
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Wed May 15 13:25:03 2013 +0200

    [2836] Conditional code compilation
    
    Skip some code if no shared memory support is present.

commit 61e6c39d6f14c8d06956e92002b53f9448453b4d
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Wed May 15 13:17:22 2013 +0200

    [2836] Update Id generation
    
    Use bigger type, check it never overflows.

commit 598d81ecdbc43b8e6869ba65c60b1d7b4fb155e3
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Wed May 15 13:17:09 2013 +0200

    [2836] Update the docs about trees

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

Summary of changes:
 src/lib/datasrc/memory/domaintree.h                |   29 +++++++++++---------
 src/lib/datasrc/memory/segment_object_holder.cc    |   10 +++++--
 src/lib/datasrc/memory/segment_object_holder.h     |    7 +++--
 .../tests/memory/segment_object_holder_unittest.cc |    6 ++--
 4 files changed, 31 insertions(+), 21 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/memory/domaintree.h b/src/lib/datasrc/memory/domaintree.h
index d0a36e7..827b3d7 100644
--- a/src/lib/datasrc/memory/domaintree.h
+++ b/src/lib/datasrc/memory/domaintree.h
@@ -1301,21 +1301,24 @@ public:
     /// doesn't exist.
     ///
     /// This method normally involves resource allocation.  If it fails
-    /// the corresponding standard exception will be thrown.
+    /// \c std::bad_alloc will be thrown.  Also, depending on details the
+    /// specific \c MemorySegment, it can propagate the \c MemorySegmentGrown
+    /// exception.
     ///
     /// This method does not provide the strong exception guarantee in its
-    /// strict sense; if an exception is thrown in the middle of this
-    /// method, the internal structure may change.  However, it should
-    /// still retain the same property as a mapping container before this
-    /// method is called.  For example, the result of \c find() should be
-    /// the same.  This method provides the weak exception guarantee in its
-    /// normal sense.
-    ///
-    /// In particular, this method can propagate the \c MemorySegmentGrown
-    /// exception from the \c MemorySegment object. In such case, some of
-    /// the internal nodes may have been already allocated (but hold no data).
-    /// Retrying the insert (possibly multiple times) would lead to the same
-    /// structure eventually.
+    /// strict sense; there can be new empty nodes that are superdomains of
+    /// the domain to be inserted as a side effect.  However, the tree
+    /// retains internal integrity otherwise, and, in particular, the intended
+    /// insert operation is "resumable": if the \c insert() method is called
+    /// again with the same argument after resolving the cause of the
+    /// exception (possibly multiple times), it should now succeed.  Note,
+    /// however, that i case of \c MemorySegmentGrown the address of the
+    /// `DomainTree` object may have been reallocated if it was created with
+    /// the same \c MemorySegment (which will often be the case in practice).
+    /// So the caller may have to re-get the address before calling \c insert
+    /// again.  It can be done using the concept of "named addresses" of
+    /// \c MemorySegment, or the direct caller may not have to worry about it
+    /// if this condition is guaranteed at a higher level.
     ///
     /// \param mem_sgmt A \c MemorySegment object for allocating memory of
     /// a new node to be inserted.  Must be the same segment as that used
diff --git a/src/lib/datasrc/memory/segment_object_holder.cc b/src/lib/datasrc/memory/segment_object_holder.cc
index 9ca9d3c..40c5ef7 100644
--- a/src/lib/datasrc/memory/segment_object_holder.cc
+++ b/src/lib/datasrc/memory/segment_object_holder.cc
@@ -16,6 +16,8 @@
 
 #include <boost/lexical_cast.hpp>
 
+#include <cassert>
+
 namespace isc {
 namespace datasrc {
 namespace memory {
@@ -23,9 +25,13 @@ namespace detail {
 
 std::string
 getNextHolderName() {
-    static size_t index = 0;
+    static uint64_t index = 0;
+    ++index;
+    // in practice we should be able to assume this, uint64 is large
+    // and should not overflow
+    assert(index != 0);
     return ("Segment object holder auto name " +
-            boost::lexical_cast<std::string>(index ++));
+            boost::lexical_cast<std::string>(index));
 }
 
 }
diff --git a/src/lib/datasrc/memory/segment_object_holder.h b/src/lib/datasrc/memory/segment_object_holder.h
index 91c7127..62b5a1c 100644
--- a/src/lib/datasrc/memory/segment_object_holder.h
+++ b/src/lib/datasrc/memory/segment_object_holder.h
@@ -27,9 +27,10 @@ namespace detail {
 // Internal function to get next yet unused name of segment holder.
 // We need the names of holders to be unique per segment at any given
 // momemnt. This just keeps incrementing number after a prefix with
-// each call, it should be enough (the holder should no longer be
-// alive when the counter wraps around, if that ever happens with
-// presumably 64bit counters).
+// each call, it should be enough (we assert it does not wrap around,
+// but 64bits should be enough).
+//
+// Also, it is not thread safe.
 std::string
 getNextHolderName();
 
diff --git a/src/lib/datasrc/tests/memory/segment_object_holder_unittest.cc b/src/lib/datasrc/tests/memory/segment_object_holder_unittest.cc
index 2d36952..f0134e8 100644
--- a/src/lib/datasrc/tests/memory/segment_object_holder_unittest.cc
+++ b/src/lib/datasrc/tests/memory/segment_object_holder_unittest.cc
@@ -17,7 +17,9 @@
 
 #include <datasrc/memory/segment_object_holder.h>
 
+#ifdef USE_SHARED_MEMORY
 #include <boost/interprocess/managed_mapped_file.hpp>
+#endif
 
 #include <gtest/gtest.h>
 
@@ -103,9 +105,6 @@ allocateUntilGrows(MemorySegment& segment, size_t& current_size) {
 // SegmentGrown exception and the thing moves address
 #ifdef USE_SHARED_MEMORY
 TEST(SegmentObjectHolderTest, grow) {
-#else
-TEST(SegmentObjectHolderTest, DISABLED_grow) {
-#endif
     MemorySegmentMapped segment(mapped_file,
                                 isc::util::MemorySegmentMapped::CREATE_ONLY);
     // Allocate a bit of memory, to get a unique address
@@ -137,5 +136,6 @@ TEST(SegmentObjectHolderTest, DISABLED_grow) {
     // Remove the file
     EXPECT_EQ(0, unlink(mapped_file));
 }
+#endif
 
 }



More information about the bind10-changes mailing list