BIND 10 trac2831, updated. 14023798bdf7385a96500cf8bb7d93d485def18a [2831] skip death test if run on valgrind
BIND 10 source code commits
bind10-changes at lists.isc.org
Wed Mar 13 07:28:48 UTC 2013
The branch, trac2831 has been updated
via 14023798bdf7385a96500cf8bb7d93d485def18a (commit)
via 8e75dec19bbdb3ae1e01558ed5bb8cd89ad45582 (commit)
from bb5479f56b9bdab1eff81e8ecca1d8e703a9ef50 (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 14023798bdf7385a96500cf8bb7d93d485def18a
Author: JINMEI Tatuya <jinmei at isc.org>
Date: Wed Mar 13 00:28:22 2013 -0700
[2831] skip death test if run on valgrind
commit 8e75dec19bbdb3ae1e01558ed5bb8cd89ad45582
Author: JINMEI Tatuya <jinmei at isc.org>
Date: Wed Mar 13 00:25:43 2013 -0700
[2831] use null mutex for managed mapped file.
it eliminates possible dependency on pthread library (which is not needed
for the memory segment class) and possible build time troubles due to that.
-----------------------------------------------------------------------
Summary of changes:
src/lib/util/memory_segment_mapped.cc | 37 +++++++++++---------
.../util/tests/memory_segment_mapped_unittest.cc | 15 ++++----
2 files changed, 30 insertions(+), 22 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/util/memory_segment_mapped.cc b/src/lib/util/memory_segment_mapped.cc
index 9aed111..c3ae717 100644
--- a/src/lib/util/memory_segment_mapped.cc
+++ b/src/lib/util/memory_segment_mapped.cc
@@ -24,27 +24,34 @@
#include <string>
#include <new>
-using boost::interprocess::managed_mapped_file;
-using boost::interprocess::open_or_create;
-using boost::interprocess::open_only;
-using boost::interprocess::open_read_only;
-using boost::interprocess::offset_ptr;
+using namespace boost::interprocess;
namespace isc {
namespace util {
+// We customize managed_mapped_file to make it completely lock free. In our
+// usage the application (or the system of applications) is expected to ensure
+// there's at most one writer process or concurrent writing the shared memory
+// segment is protected at a higher level. Using the null mutex is mainly for
+// eliminating unnecessary dependency; the default version would require
+// (probably depending on the system) Pthread library that is actually not
+// needed and could cause various build time troubles.
+typedef basic_managed_mapped_file<char,
+ rbtree_best_fit<null_mutex_family>,
+ iset_index> BaseSegment;
+
struct MemorySegmentMapped::Impl {
Impl(const std::string& filename, size_t initial_size) :
read_only_(false), filename_(filename),
- base_sgmt_(new managed_mapped_file(open_or_create, filename.c_str(),
- initial_size))
+ base_sgmt_(new BaseSegment(open_or_create, filename.c_str(),
+ initial_size))
{}
Impl(const std::string& filename, bool read_only) :
read_only_(read_only), filename_(filename),
base_sgmt_(read_only ?
- new managed_mapped_file(open_read_only, filename.c_str()) :
- new managed_mapped_file(open_only, filename.c_str()))
+ new BaseSegment(open_read_only, filename.c_str()) :
+ new BaseSegment(open_only, filename.c_str()))
{}
// Internal helper to grow the underlying mapped segment.
@@ -57,8 +64,7 @@ struct MemorySegmentMapped::Impl {
const size_t new_size = prev_size * 2;
assert(new_size != 0); // assume grow fails before size overflow
- if (!managed_mapped_file::grow(filename_.c_str(),
- new_size - prev_size))
+ if (!BaseSegment::grow(filename_.c_str(), new_size - prev_size))
{
throw std::bad_alloc();
}
@@ -67,8 +73,7 @@ struct MemorySegmentMapped::Impl {
// Remap the grown file; this should succeed, but it's not 100%
// guaranteed. If it fails we treat it as if we fail to create
// the new segment.
- base_sgmt_.reset(new managed_mapped_file(open_only,
- filename_.c_str()));
+ base_sgmt_.reset(new BaseSegment(open_only, filename_.c_str()));
} catch (const boost::interprocess::interprocess_exception& ex) {
throw std::bad_alloc();
}
@@ -81,7 +86,7 @@ struct MemorySegmentMapped::Impl {
const std::string filename_;
// actual Boost implementation of mapped segment.
- boost::scoped_ptr<managed_mapped_file> base_sgmt_;
+ boost::scoped_ptr<BaseSegment> base_sgmt_;
};
MemorySegmentMapped::MemorySegmentMapped(const std::string& filename) :
@@ -224,13 +229,13 @@ MemorySegmentMapped::shrinkToFit() {
}
impl_->base_sgmt_.reset();
- managed_mapped_file::shrink_to_fit(impl_->filename_.c_str());
+ BaseSegment::shrink_to_fit(impl_->filename_.c_str());
try {
// Remap the grown file; this should succeed, but it's not 100%
// guaranteed. If it fails we treat it as if we fail to create
// the new segment.
impl_->base_sgmt_.reset(
- new managed_mapped_file(open_only, impl_->filename_.c_str()));
+ new BaseSegment(open_only, impl_->filename_.c_str()));
} catch (const boost::interprocess::interprocess_exception& ex) {
isc_throw(MemorySegmentError,
"remap after shrink failed; segment is now unusable");
diff --git a/src/lib/util/tests/memory_segment_mapped_unittest.cc b/src/lib/util/tests/memory_segment_mapped_unittest.cc
index c8082ac..1c87403 100644
--- a/src/lib/util/tests/memory_segment_mapped_unittest.cc
+++ b/src/lib/util/tests/memory_segment_mapped_unittest.cc
@@ -13,6 +13,7 @@
// PERFORMANCE OF THIS SOFTWARE.
#include <util/tests/memory_segment_common_unittest.h>
+#include <util/unittests/check_valgrind.h>
#include <util/memory_segment_mapped.h>
#include <exceptions/exceptions.h>
@@ -185,12 +186,14 @@ TEST_F(MemorySegmentMappedTest, badDeallocate) {
// Deallocating at an invalid address; this would result in crash (the
// behavior may not be portable enough; if so we should disable it by
// default).
- ptr = segment_->allocate(4);
- EXPECT_NE(static_cast<void*>(0), ptr);
- EXPECT_DEATH_IF_SUPPORTED({
- segment_->deallocate(static_cast<char*>(ptr) + 1, 3);
- }, "");
- resetSegment();
+ if (!isc::util::unittests::runningOnValgrind()) {
+ ptr = segment_->allocate(4);
+ EXPECT_NE(static_cast<void*>(0), ptr);
+ EXPECT_DEATH_IF_SUPPORTED({
+ segment_->deallocate(static_cast<char*>(ptr) + 1, 3);
+ }, "");
+ resetSegment();
+ }
// Invalid size; this implementation doesn't detect such errors.
ptr = segment_->allocate(4);
More information about the bind10-changes
mailing list