BIND 10 trac1704_2, updated. 6b3132f71b397e4925b80ed1dc1e3cb834be1294 [1704] Use a null InterprocessSync object for some tests
BIND 10 source code commits
bind10-changes at lists.isc.org
Mon May 28 07:51:50 UTC 2012
The branch, trac1704_2 has been updated
via 6b3132f71b397e4925b80ed1dc1e3cb834be1294 (commit)
via 865669e98402f25c41f35e3957bdb9190513bf6f (commit)
via 58c0a8ef0152662b581b7a13fecf92ed0b0021e8 (commit)
via 8c38fe10458178dee5a0045ae2bfa3da986d6a0c (commit)
from e007ac3e1fb0595497757b3590c3023c825965d4 (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 6b3132f71b397e4925b80ed1dc1e3cb834be1294
Author: Mukund Sivaraman <muks at isc.org>
Date: Mon May 28 13:19:13 2012 +0530
[1704] Use a null InterprocessSync object for some tests
This makes some tests pass which uses logger_example, which is
a standalone binary.
commit 865669e98402f25c41f35e3957bdb9190513bf6f
Author: Mukund Sivaraman <muks at isc.org>
Date: Mon May 28 12:54:24 2012 +0530
[1704] Update documentation
commit 58c0a8ef0152662b581b7a13fecf92ed0b0021e8
Author: Mukund Sivaraman <muks at isc.org>
Date: Mon May 28 12:44:15 2012 +0530
[1704] Set and use B10_LOCKFILE_DIR_FROM_BUILD in tests
* Also set this env variable in isc::log::initLogger()
commit 8c38fe10458178dee5a0045ae2bfa3da986d6a0c
Author: Mukund Sivaraman <muks at isc.org>
Date: Mon May 28 11:48:49 2012 +0530
[1704] Remove log_test_messages.{cc,h} from the tree
They are auto-generated during build now.
-----------------------------------------------------------------------
Summary of changes:
src/bin/bind10/bind10_src.py.in | 2 +
src/bin/bind10/tests/Makefile.am | 1 +
src/bin/bind10/tests/bind10_test.py.in | 33 ++++++-------
src/lib/log/Makefile.am | 1 +
src/lib/log/logger_manager.cc | 5 ++
src/lib/log/logger_unittest_support.cc | 3 ++
src/lib/log/tests/.gitignore | 2 +
src/lib/log/tests/Makefile.am | 1 -
src/lib/log/tests/console_test.sh.in | 2 -
src/lib/log/tests/destination_test.sh.in | 2 -
src/lib/log/tests/init_logger_test.sh.in | 2 -
src/lib/log/tests/local_file_test.sh.in | 2 -
src/lib/log/tests/log_test_messages.cc | 25 ----------
src/lib/log/tests/log_test_messages.h | 16 ------
src/lib/log/tests/logger_example.cc | 4 ++
src/lib/log/tests/run_initializer_unittests.cc | 1 -
src/lib/log/tests/severity_test.sh.in | 2 -
src/lib/python/isc/log/tests/Makefile.am | 2 +-
src/lib/util/Makefile.am | 4 +-
src/lib/util/interprocess_sync.h | 20 ++++++++
src/lib/util/interprocess_sync_file.cc | 5 ++
src/lib/util/interprocess_sync_file.h | 8 ++-
.../logger.cc => util/interprocess_sync_null.cc} | 22 +++++++--
...rocess_sync_file.h => interprocess_sync_null.h} | 52 +++++++-------------
24 files changed, 104 insertions(+), 113 deletions(-)
delete mode 100644 src/lib/log/tests/log_test_messages.cc
delete mode 100644 src/lib/log/tests/log_test_messages.h
copy src/lib/{asiodns/logger.cc => util/interprocess_sync_null.cc} (71%)
copy src/lib/util/{interprocess_sync_file.h => interprocess_sync_null.h} (51%)
-----------------------------------------------------------------------
diff --git a/src/bin/bind10/bind10_src.py.in b/src/bin/bind10/bind10_src.py.in
index 0091eac..08e16c6 100755
--- a/src/bin/bind10/bind10_src.py.in
+++ b/src/bin/bind10/bind10_src.py.in
@@ -1136,6 +1136,8 @@ def remove_lock_files():
lpath = os.environ["B10_FROM_BUILD"]
if "B10_FROM_SOURCE_LOCALSTATEDIR" in os.environ:
lpath = os.environ["B10_FROM_SOURCE_LOCALSTATEDIR"]
+ if "B10_LOCKFILE_DIR_FROM_BUILD" in os.environ:
+ lpath = os.environ["B10_LOCKFILE_DIR_FROM_BUILD"]
for f in lockfiles:
fname = lpath + '/' + f
diff --git a/src/bin/bind10/tests/Makefile.am b/src/bin/bind10/tests/Makefile.am
index d54ee56..a5e3fab 100644
--- a/src/bin/bind10/tests/Makefile.am
+++ b/src/bin/bind10/tests/Makefile.am
@@ -23,6 +23,7 @@ endif
chmod +x $(abs_builddir)/$$pytest ; \
$(LIBRARY_PATH_PLACEHOLDER) \
PYTHONPATH=$(COMMON_PYTHON_PATH):$(abs_top_srcdir)/src/bin:$(abs_top_builddir)/src/bin/bind10:$(abs_top_builddir)/src/lib/util/io/.libs \
+ B10_LOCKFILE_DIR_FROM_BUILD=$(abs_top_builddir) \
BIND10_MSGQ_SOCKET_FILE=$(abs_top_builddir)/msgq_socket \
$(PYCOVERAGE_RUN) $(abs_builddir)/$$pytest || exit ; \
done
diff --git a/src/bin/bind10/tests/bind10_test.py.in b/src/bin/bind10/tests/bind10_test.py.in
index 5a6ab08..6924dc9 100644
--- a/src/bin/bind10/tests/bind10_test.py.in
+++ b/src/bin/bind10/tests/bind10_test.py.in
@@ -684,7 +684,13 @@ class TestStartStopProcessesBob(unittest.TestCase):
"""
def check_environment_unchanged(self):
# Check whether the environment has not been changed
- self.assertEqual(original_os_environ, os.environ)
+ cur_os_environ = copy.deepcopy(os.environ)
+ if "B10_LOCKFILE_DIR_FROM_BUILD" in original_os_environ:
+ original_os_environ.pop("B10_LOCKFILE_DIR_FROM_BUILD")
+ if "B10_LOCKFILE_DIR_FROM_BUILD" in cur_os_environ:
+ cur_os_environ.pop("B10_LOCKFILE_DIR_FROM_BUILD")
+
+ self.assertEqual(original_os_environ, cur_os_environ)
def check_started(self, bob, core, auth, resolver):
"""
@@ -1466,28 +1472,24 @@ class SocketSrvTest(unittest.TestCase):
class TestFunctions(unittest.TestCase):
def setUp(self):
self.lockfile_testpath = "@abs_top_builddir@/src/bin/bind10/tests/lockfile_test"
- if not os.path.isdir(self.lockfile_testpath):
- os.mkdir(self.lockfile_testpath)
+ self.assertFalse(os.path.exists(self.lockfile_testpath))
+ os.mkdir(self.lockfile_testpath)
self.assertTrue(os.path.isdir(self.lockfile_testpath))
def tearDown(self):
os.rmdir(self.lockfile_testpath)
self.assertFalse(os.path.isdir(self.lockfile_testpath))
+ os.environ["B10_LOCKFILE_DIR_FROM_BUILD"] = "@abs_top_builddir@"
def test_remove_lock_files(self):
- if "B10_FROM_BUILD" in os.environ:
- oldenv = os.environ["B10_FROM_BUILD"]
- else:
- oldenv = None
-
- os.environ["B10_FROM_BUILD"] = self.lockfile_testpath
+ os.environ["B10_LOCKFILE_DIR_FROM_BUILD"] = self.lockfile_testpath
# create lockfiles for the testcase
lockfiles = ["logger_lockfile"]
for f in lockfiles:
- fname = os.environ["B10_FROM_BUILD"] + '/' + f
- if not os.path.isfile(fname):
- open(fname, "w").close()
+ fname = os.environ["B10_LOCKFILE_DIR_FROM_BUILD"] + '/' + f
+ self.assertFalse(os.path.exists(fname))
+ open(fname, "w").close()
self.assertTrue(os.path.isfile(fname))
# first call should clear up all the lockfiles
@@ -1495,17 +1497,12 @@ class TestFunctions(unittest.TestCase):
# check if the lockfiles exist
for f in lockfiles:
- fname = os.environ["B10_FROM_BUILD"] + '/' + f
+ fname = os.environ["B10_LOCKFILE_DIR_FROM_BUILD"] + '/' + f
self.assertFalse(os.path.isfile(fname))
# second call should not assert anyway
bind10_src.remove_lock_files()
- if oldenv is not None:
- os.environ["B10_FROM_BUILD"] = oldenv
- else:
- os.environ.pop("B10_FROM_BUILD")
-
if __name__ == '__main__':
# store os.environ for test_unchanged_environment
original_os_environ = copy.deepcopy(os.environ)
diff --git a/src/lib/log/Makefile.am b/src/lib/log/Makefile.am
index b82eb1b..fb3aed7 100644
--- a/src/lib/log/Makefile.am
+++ b/src/lib/log/Makefile.am
@@ -2,6 +2,7 @@ SUBDIRS = . compiler tests
AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib
AM_CPPFLAGS += $(BOOST_INCLUDES)
+AM_CPPFLAGS += -DTOP_BUILDDIR=\"${abs_top_builddir}\"
CLEANFILES = *.gcno *.gcda
diff --git a/src/lib/log/logger_manager.cc b/src/lib/log/logger_manager.cc
index 8a8a36b..164e226 100644
--- a/src/lib/log/logger_manager.cc
+++ b/src/lib/log/logger_manager.cc
@@ -28,6 +28,7 @@
#include <log/message_initializer.h>
#include <log/message_reader.h>
#include <log/message_types.h>
+#include "util/interprocess_sync_null.h"
using namespace std;
@@ -148,6 +149,10 @@ LoggerManager::readLocalMessageFile(const char* file) {
MessageDictionary& dictionary = MessageDictionary::globalDictionary();
MessageReader reader(&dictionary);
+
+ // Turn off use of any lock files
+ logger.setInterprocessSync(new isc::util::InterprocessSyncNull("log"));
+
try {
logger.info(LOG_READING_LOCAL_FILE).arg(file);
diff --git a/src/lib/log/logger_unittest_support.cc b/src/lib/log/logger_unittest_support.cc
index a0969be..4f02b07 100644
--- a/src/lib/log/logger_unittest_support.cc
+++ b/src/lib/log/logger_unittest_support.cc
@@ -160,6 +160,9 @@ void initLogger(isc::log::Severity severity, int dbglevel) {
// Set the local message file
const char* localfile = getenv("B10_LOGGER_LOCALMSG");
+ // Set a directory for creating lockfiles when running tests
+ setenv("B10_LOCKFILE_DIR_FROM_BUILD", TOP_BUILDDIR, 1);
+
// Initialize logging
initLogger(root, isc::log::DEBUG, isc::log::MAX_DEBUG_LEVEL, localfile);
diff --git a/src/lib/log/tests/.gitignore b/src/lib/log/tests/.gitignore
index 41b863b..0b3711f 100644
--- a/src/lib/log/tests/.gitignore
+++ b/src/lib/log/tests/.gitignore
@@ -6,6 +6,8 @@
/initializer_unittests_2
/local_file_test.sh
/logger_example
+/log_test_messages.cc
+/log_test_messages.h
/run_unittests
/severity_test.sh
/tempdir.h
diff --git a/src/lib/log/tests/Makefile.am b/src/lib/log/tests/Makefile.am
index f09f101..2d8951f 100644
--- a/src/lib/log/tests/Makefile.am
+++ b/src/lib/log/tests/Makefile.am
@@ -2,7 +2,6 @@ SUBDIRS = .
AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib
AM_CPPFLAGS += $(BOOST_INCLUDES)
-AM_CPPFLAGS += -DTOP_BUILDDIR=\"${abs_top_builddir}\"
AM_CXXFLAGS = $(B10_CXXFLAGS)
AM_LDADD =
AM_LDFLAGS =
diff --git a/src/lib/log/tests/console_test.sh.in b/src/lib/log/tests/console_test.sh.in
index da00124..a16dc23 100755
--- a/src/lib/log/tests/console_test.sh.in
+++ b/src/lib/log/tests/console_test.sh.in
@@ -16,8 +16,6 @@
# The logger supports the idea of a "console" logger than logs to either stdout
# or stderr. This test checks that both these options work.
-export B10_FROM_BUILD=@abs_top_builddir@
-
testname="Console output test"
echo $testname
diff --git a/src/lib/log/tests/destination_test.sh.in b/src/lib/log/tests/destination_test.sh.in
index 94aaefd..1cfb9fb 100755
--- a/src/lib/log/tests/destination_test.sh.in
+++ b/src/lib/log/tests/destination_test.sh.in
@@ -15,8 +15,6 @@
# Checks that the logger will route messages to the chosen destination.
-export B10_FROM_BUILD=@abs_top_builddir@
-
testname="Destination test"
echo $testname
diff --git a/src/lib/log/tests/init_logger_test.sh.in b/src/lib/log/tests/init_logger_test.sh.in
index ac80f65..795419b 100755
--- a/src/lib/log/tests/init_logger_test.sh.in
+++ b/src/lib/log/tests/init_logger_test.sh.in
@@ -16,8 +16,6 @@
# Checks that the initLogger() call uses for unit tests respects the setting of
# the environment variables.
-export B10_FROM_BUILD=@abs_top_builddir@
-
testname="initLogger test"
echo $testname
diff --git a/src/lib/log/tests/local_file_test.sh.in b/src/lib/log/tests/local_file_test.sh.in
index d5daa45..9b898e6 100755
--- a/src/lib/log/tests/local_file_test.sh.in
+++ b/src/lib/log/tests/local_file_test.sh.in
@@ -16,8 +16,6 @@
# Checks that a local message file can override the definitions in the message
# dictionary.
-export B10_FROM_BUILD=@abs_top_builddir@
-
testname="Local message file test"
echo $testname
diff --git a/src/lib/log/tests/log_test_messages.cc b/src/lib/log/tests/log_test_messages.cc
deleted file mode 100644
index 57ee29c..0000000
--- a/src/lib/log/tests/log_test_messages.cc
+++ /dev/null
@@ -1,25 +0,0 @@
-// File created from ../../../../src/lib/log/tests/log_test_messages.mes on Mon May 28 11:38:27 2012
-
-#include <cstddef>
-#include <log/message_types.h>
-#include <log/message_initializer.h>
-
-namespace isc {
-namespace log {
-
-extern const isc::log::MessageID LOG_LOCK_TEST_MESSAGE = "LOG_LOCK_TEST_MESSAGE";
-
-} // namespace log
-} // namespace isc
-
-namespace {
-
-const char* values[] = {
- "LOG_LOCK_TEST_MESSAGE", "this is a test message.",
- NULL
-};
-
-const isc::log::MessageInitializer initializer(values);
-
-} // Anonymous namespace
-
diff --git a/src/lib/log/tests/log_test_messages.h b/src/lib/log/tests/log_test_messages.h
deleted file mode 100644
index 14553eb..0000000
--- a/src/lib/log/tests/log_test_messages.h
+++ /dev/null
@@ -1,16 +0,0 @@
-// File created from ../../../../src/lib/log/tests/log_test_messages.mes on Mon May 28 11:38:27 2012
-
-#ifndef __LOG_TEST_MESSAGES_H
-#define __LOG_TEST_MESSAGES_H
-
-#include <log/message_types.h>
-
-namespace isc {
-namespace log {
-
-extern const isc::log::MessageID LOG_LOCK_TEST_MESSAGE;
-
-} // namespace log
-} // namespace isc
-
-#endif // __LOG_TEST_MESSAGES_H
diff --git a/src/lib/log/tests/logger_example.cc b/src/lib/log/tests/logger_example.cc
index d3f08f3..991a235 100644
--- a/src/lib/log/tests/logger_example.cc
+++ b/src/lib/log/tests/logger_example.cc
@@ -41,6 +41,7 @@
// Include a set of message definitions.
#include <log/log_messages.h>
+#include "util/interprocess_sync_null.h"
using namespace isc::log;
using namespace std;
@@ -282,8 +283,11 @@ int main(int argc, char** argv) {
// Log a few messages to different loggers.
isc::log::Logger logger_ex(ROOT_NAME);
+ logger_ex.setInterprocessSync(new isc::util::InterprocessSyncNull(ROOT_NAME));
isc::log::Logger logger_alpha("alpha");
+ logger_alpha.setInterprocessSync(new isc::util::InterprocessSyncNull("alpha"));
isc::log::Logger logger_beta("beta");
+ logger_beta.setInterprocessSync(new isc::util::InterprocessSyncNull("beta"));
LOG_FATAL(logger_ex, LOG_WRITE_ERROR).arg("test1").arg("42");
LOG_ERROR(logger_ex, LOG_READING_LOCAL_FILE).arg("dummy/file");
diff --git a/src/lib/log/tests/run_initializer_unittests.cc b/src/lib/log/tests/run_initializer_unittests.cc
index 23df7b8..6660215 100644
--- a/src/lib/log/tests/run_initializer_unittests.cc
+++ b/src/lib/log/tests/run_initializer_unittests.cc
@@ -21,6 +21,5 @@
int
main(int argc, char* argv[]) {
::testing::InitGoogleTest(&argc, argv);
- setenv("B10_FROM_BUILD", TOP_BUILDDIR, 1);
return (isc::util::unittests::run_all());
}
diff --git a/src/lib/log/tests/severity_test.sh.in b/src/lib/log/tests/severity_test.sh.in
index 5390fee..78d5050 100755
--- a/src/lib/log/tests/severity_test.sh.in
+++ b/src/lib/log/tests/severity_test.sh.in
@@ -16,8 +16,6 @@
# Checks that the logger will limit the output of messages less severe than
# the severity/debug setting.
-export B10_FROM_BUILD=@abs_top_builddir@
-
testname="Severity test"
echo $testname
diff --git a/src/lib/python/isc/log/tests/Makefile.am b/src/lib/python/isc/log/tests/Makefile.am
index fe5144b..10d5326 100644
--- a/src/lib/python/isc/log/tests/Makefile.am
+++ b/src/lib/python/isc/log/tests/Makefile.am
@@ -28,7 +28,7 @@ endif
$(LIBRARY_PATH_PLACEHOLDER) \
PYTHONPATH=$(COMMON_PYTHON_PATH):$(abs_top_builddir)/src/lib/python/isc/log:$(abs_top_builddir)/src/lib/log/python/.libs \
B10_TEST_PLUGIN_DIR=$(abs_top_srcdir)/src/bin/cfgmgr/plugins \
- B10_FROM_BUILD=$(abs_top_builddir) \
+ B10_LOCKFILE_DIR_FROM_BUILD=$(abs_top_builddir) \
$(PYCOVERAGE_RUN) $(abs_srcdir)/$$pytest || exit ; \
done ; \
for pytest in $(PYTESTS_GEN) ; do \
diff --git a/src/lib/util/Makefile.am b/src/lib/util/Makefile.am
index 7f2a48c..fad2465 100644
--- a/src/lib/util/Makefile.am
+++ b/src/lib/util/Makefile.am
@@ -13,7 +13,9 @@ libutil_la_SOURCES += locks.h lru_list.h
libutil_la_SOURCES += strutil.h strutil.cc
libutil_la_SOURCES += buffer.h io_utilities.h
libutil_la_SOURCES += time_utilities.h time_utilities.cc
-libutil_la_SOURCES += interprocess_sync.h interprocess_sync_file.h interprocess_sync_file.cc
+libutil_la_SOURCES += interprocess_sync.h
+libutil_la_SOURCES += interprocess_sync_file.h interprocess_sync_file.cc
+libutil_la_SOURCES += interprocess_sync_null.h interprocess_sync_null.cc
libutil_la_SOURCES += range_utilities.h
libutil_la_SOURCES += hash/sha1.h hash/sha1.cc
libutil_la_SOURCES += encode/base16_from_binary.h
diff --git a/src/lib/util/interprocess_sync.h b/src/lib/util/interprocess_sync.h
index 9646f64..b04c37f 100644
--- a/src/lib/util/interprocess_sync.h
+++ b/src/lib/util/interprocess_sync.h
@@ -62,10 +62,18 @@ public:
protected:
/// \brief Acquire the lock (blocks if something else has acquired a
/// lock on the same task name)
+ ///
+ /// \return Returns true if the lock was acquired, false otherwise.
virtual bool lock() = 0;
+
/// \brief Try to acquire a lock (doesn't block)
+ ///
+ /// \return Returns true if the lock was acquired, false otherwise.
virtual bool tryLock() = 0;
+
/// \brief Release the lock
+ ///
+ /// \return Returns true if the lock was released, false otherwise.
virtual bool unlock() = 0;
const std::string task_name_; ///< The task name
@@ -80,6 +88,12 @@ protected:
/// the description of InterprocessSync.
class InterprocessSyncLocker {
public:
+ /// \brief Constructor
+ ///
+ /// Creates a lock manager around a interprocess synchronization object
+ ///
+ /// \param sync The sync object which has to be locked/unlocked by
+ /// this locker object.
InterprocessSyncLocker(InterprocessSync& sync) :
sync_(sync)
{}
@@ -91,16 +105,22 @@ public:
/// \brief Acquire the lock (blocks if something else has acquired a
/// lock on the same task name)
+ ///
+ /// \return Returns true if the lock was acquired, false otherwise.
bool lock() {
return (sync_.lock());
}
/// \brief Try to acquire a lock (doesn't block)
+ ///
+ /// \return Returns true if the lock was acquired, false otherwise.
bool tryLock() {
return (sync_.tryLock());
}
/// \brief Release the lock
+ ///
+ /// \return Returns true if the lock was released, false otherwise.
bool unlock() {
return (sync_.unlock());
}
diff --git a/src/lib/util/interprocess_sync_file.cc b/src/lib/util/interprocess_sync_file.cc
index f035b7d..d045449 100644
--- a/src/lib/util/interprocess_sync_file.cc
+++ b/src/lib/util/interprocess_sync_file.cc
@@ -53,6 +53,11 @@ InterprocessSyncFile::do_lock(int cmd, short l_type) {
lockfile_path = env2;
}
+ const char* const env3 = getenv("B10_LOCKFILE_DIR_FROM_BUILD");
+ if (env3 != NULL) {
+ lockfile_path = env3;
+ }
+
lockfile_path += "/" + task_name_ + "_lockfile";
// Open the lockfile in the constructor so it doesn't do the access
diff --git a/src/lib/util/interprocess_sync_file.h b/src/lib/util/interprocess_sync_file.h
index 7030747..84016a6 100644
--- a/src/lib/util/interprocess_sync_file.h
+++ b/src/lib/util/interprocess_sync_file.h
@@ -62,18 +62,24 @@ public:
protected:
/// \brief Acquire the lock (blocks if something else has acquired a
/// lock on the same task name)
+ ///
+ /// \return Returns true if the lock was acquired, false otherwise.
bool lock();
/// \brief Try to acquire a lock (doesn't block)
+ ///
+ /// \return Returns true if the lock was acquired, false otherwise.
bool tryLock();
/// \brief Release the lock
+ ///
+ /// \return Returns true if the lock was released, false otherwise.
bool unlock();
private:
bool do_lock(int cmd, short l_type);
- int fd_;
+ int fd_; ///< The descriptor for the open file
};
} // namespace util
diff --git a/src/lib/util/interprocess_sync_null.cc b/src/lib/util/interprocess_sync_null.cc
new file mode 100644
index 0000000..e2cfc9b
--- /dev/null
+++ b/src/lib/util/interprocess_sync_null.cc
@@ -0,0 +1,39 @@
+// 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 "interprocess_sync_null.h"
+
+namespace isc {
+namespace util {
+
+InterprocessSyncNull::~InterprocessSyncNull() {
+}
+
+bool
+InterprocessSyncNull::lock() {
+ return (true);
+}
+
+bool
+InterprocessSyncNull::tryLock() {
+ return (true);
+}
+
+bool
+InterprocessSyncNull::unlock() {
+ return (true);
+}
+
+} // namespace util
+} // namespace isc
diff --git a/src/lib/util/interprocess_sync_null.h b/src/lib/util/interprocess_sync_null.h
new file mode 100644
index 0000000..150d585
--- /dev/null
+++ b/src/lib/util/interprocess_sync_null.h
@@ -0,0 +1,64 @@
+// 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 __INTERPROCESS_SYNC_NULL_H__
+#define __INTERPROCESS_SYNC_NULL_H__
+
+#include "util/interprocess_sync.h"
+
+namespace isc {
+namespace util {
+
+/// \brief Null Interprocess Sync Class
+///
+/// This class specifies a concrete implementation for a null (no effect)
+/// interprocess synchronization mechanism. Please see the
+/// InterprocessSync class documentation for usage.
+class InterprocessSyncNull : public InterprocessSync {
+public:
+ /// \brief Constructor
+ ///
+ /// Creates a null interprocess synchronization object
+ ///
+ /// \param name Name of the synchronization task. This has to be
+ /// identical among the various processes that need to be
+ /// synchronized for the same task.
+ InterprocessSyncNull(const std::string& task_name) :
+ InterprocessSync(task_name)
+ {}
+
+ /// \brief Destructor
+ virtual ~InterprocessSyncNull();
+
+protected:
+ /// \brief Acquire the lock (never blocks)
+ ///
+ /// \return Always returns true
+ bool lock();
+
+ /// \brief Try to acquire a lock (doesn't block)
+ ///
+ /// \return Always returns true
+ bool tryLock();
+
+ /// \brief Release the lock
+ ///
+ /// \return Always returns true
+ bool unlock();
+};
+
+} // namespace util
+} // namespace isc
+
+#endif // __INTERPROCESS_SYNC_NULL_H__
More information about the bind10-changes
mailing list