BIND 10 trac1704_2, updated. fcb63453e3d835fdca05146482d001035cdbd6af [1704] Throw if NULL is passed to logger.setInterprocessSync()
BIND 10 source code commits
bind10-changes at lists.isc.org
Mon May 28 06:03:48 UTC 2012
The branch, trac1704_2 has been updated
via fcb63453e3d835fdca05146482d001035cdbd6af (commit)
via cd373315919dd5a20440d27d49c3c0e47ebb3f19 (commit)
via 277be10c905a1b592cc8ddb2ded6f066c619a0f2 (commit)
via 8eb4eb3e63b8f19155ae8f021436c881d75706c6 (commit)
via e72bc121a7f7e4a85f889a6c1c4eec5bafd51325 (commit)
from 075eef9a1fe8c61c69532ce8b9dc05eda102f08d (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 fcb63453e3d835fdca05146482d001035cdbd6af
Author: Mukund Sivaraman <muks at isc.org>
Date: Mon May 28 11:32:41 2012 +0530
[1704] Throw if NULL is passed to logger.setInterprocessSync()
commit cd373315919dd5a20440d27d49c3c0e47ebb3f19
Author: Mukund Sivaraman <muks at isc.org>
Date: Mon May 28 11:10:40 2012 +0530
[1704] Use @abs_top_builddir@ directly in the .py.in file instead of using an env variable
commit 277be10c905a1b592cc8ddb2ded6f066c619a0f2
Author: Mukund Sivaraman <muks at isc.org>
Date: Mon May 28 11:05:13 2012 +0530
[1704] Assert that the lockfiles exist
commit 8eb4eb3e63b8f19155ae8f021436c881d75706c6
Author: Mukund Sivaraman <muks at isc.org>
Date: Mon May 28 11:02:39 2012 +0530
[1704] Assert that the lockfile_test directory exists, and is removed
commit e72bc121a7f7e4a85f889a6c1c4eec5bafd51325
Author: Mukund Sivaraman <muks at isc.org>
Date: Mon May 28 10:25:47 2012 +0530
[1704] Move test directory creation to setUp() / tearDown()
-----------------------------------------------------------------------
Summary of changes:
src/bin/bind10/tests/Makefile.am | 1 -
src/bin/bind10/tests/bind10_test.py.in | 18 ++++++++++++------
src/lib/log/logger.h | 23 ++++++++++++++++-------
src/lib/log/logger_impl.cc | 4 +---
src/lib/log/logger_impl.h | 12 +++++-------
src/lib/log/tests/logger_unittest.cc | 7 +++++++
6 files changed, 41 insertions(+), 24 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/bind10/tests/Makefile.am b/src/bin/bind10/tests/Makefile.am
index 82958af..d54ee56 100644
--- a/src/bin/bind10/tests/Makefile.am
+++ b/src/bin/bind10/tests/Makefile.am
@@ -23,7 +23,6 @@ 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 \
- LOCKFILE_TESTPATH=$(abs_top_builddir)/src/bin/bind10/tests/lockfile_test \
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 345e053..5a6ab08 100644
--- a/src/bin/bind10/tests/bind10_test.py.in
+++ b/src/bin/bind10/tests/bind10_test.py.in
@@ -1464,16 +1464,23 @@ class SocketSrvTest(unittest.TestCase):
self.assertTrue(sock.closed)
class TestFunctions(unittest.TestCase):
- def test_remove_lock_files(self):
- if not os.path.isdir(os.environ["LOCKFILE_TESTPATH"]):
- os.mkdir(os.environ["LOCKFILE_TESTPATH"])
+ 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.assertTrue(os.path.isdir(self.lockfile_testpath))
+
+ def tearDown(self):
+ os.rmdir(self.lockfile_testpath)
+ self.assertFalse(os.path.isdir(self.lockfile_testpath))
+ 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"] = os.environ["LOCKFILE_TESTPATH"]
+ os.environ["B10_FROM_BUILD"] = self.lockfile_testpath
# create lockfiles for the testcase
lockfiles = ["logger_lockfile"]
@@ -1481,6 +1488,7 @@ class TestFunctions(unittest.TestCase):
fname = os.environ["B10_FROM_BUILD"] + '/' + f
if not os.path.isfile(fname):
open(fname, "w").close()
+ self.assertTrue(os.path.isfile(fname))
# first call should clear up all the lockfiles
bind10_src.remove_lock_files()
@@ -1493,8 +1501,6 @@ class TestFunctions(unittest.TestCase):
# second call should not assert anyway
bind10_src.remove_lock_files()
- os.rmdir(os.environ["LOCKFILE_TESTPATH"])
-
if oldenv is not None:
os.environ["B10_FROM_BUILD"] = oldenv
else:
diff --git a/src/lib/log/logger.h b/src/lib/log/logger.h
index 77be7ef..6405488 100644
--- a/src/lib/log/logger.h
+++ b/src/lib/log/logger.h
@@ -99,6 +99,17 @@ public:
{}
};
+/// \brief Bad Interprocess Sync
+///
+/// Exception thrown if a bad InterprocessSync object (such as NULL) is
+/// used.
+class BadInterprocessSync : public isc::Exception {
+public:
+ BadInterprocessSync(const char* file, size_t line, const char* what) :
+ isc::Exception(file, line, what)
+ {}
+};
+
/// \brief Logger Class
///
/// This class is the main class used for logging. Use comprises:
@@ -240,15 +251,13 @@ public:
/// \brief Replace the interprocess synchronization object
///
- /// This method is exception-free. If this method is called with
- /// NULL as the argument, it does nothing and the old sync object is
- /// used as before.
+ /// If this method is called with NULL as the argument, it throws a
+ /// BadInterprocessSync exception.
///
/// \param sync The logger uses this synchronization object for
- /// synchronizing output of log messages. If NULL is passed, the old
- /// synchronization object is used as before. When a non-NULL sync
- /// object is passed, it should be deletable and the ownership is
- /// transferred to the logger.
+ /// synchronizing output of log messages. It should be deletable and
+ /// the ownership is transferred to the logger. If NULL is passed,
+ /// a BadInterprocessSync exception is thrown.
void setInterprocessSync(isc::util::InterprocessSync* sync);
/// \brief Equality
diff --git a/src/lib/log/logger_impl.cc b/src/lib/log/logger_impl.cc
index 974d0c2..d53e57d 100644
--- a/src/lib/log/logger_impl.cc
+++ b/src/lib/log/logger_impl.cc
@@ -111,10 +111,8 @@ LoggerImpl::lookupMessage(const MessageID& ident) {
void
LoggerImpl::setInterprocessSync(isc::util::InterprocessSync* sync) {
- // If we are passed NULL, change nothing. The old sync_ object will
- // continue to be used.
if (sync == NULL) {
- return;
+ isc_throw(BadInterprocessSync, "NULL was passed to setInterprocessSync()");
}
delete sync_;
diff --git a/src/lib/log/logger_impl.h b/src/lib/log/logger_impl.h
index 43d8aa2..10d3db4 100644
--- a/src/lib/log/logger_impl.h
+++ b/src/lib/log/logger_impl.h
@@ -171,15 +171,13 @@ public:
/// \brief Replace the interprocess synchronization object
///
- /// This method is exception-free. If this method is called with
- /// NULL as the argument, it does nothing and the old sync object is
- /// used as before.
+ /// If this method is called with NULL as the argument, it throws a
+ /// BadInterprocessSync exception.
///
/// \param sync The logger uses this synchronization object for
- /// synchronizing output of log messages. If NULL is passed, the old
- /// synchronization object is used as before. When a non-NULL sync
- /// object is passed, it should be deletable and the ownership is
- /// transferred to the logger implementation.
+ /// synchronizing output of log messages. It should be deletable and
+ /// the ownership is transferred to the logger implementation.
+ /// If NULL is passed, a BadInterprocessSync exception is thrown.
void setInterprocessSync(isc::util::InterprocessSync* sync);
/// \brief Equality
diff --git a/src/lib/log/tests/logger_unittest.cc b/src/lib/log/tests/logger_unittest.cc
index 9416bfa..a9330a9 100644
--- a/src/lib/log/tests/logger_unittest.cc
+++ b/src/lib/log/tests/logger_unittest.cc
@@ -383,6 +383,13 @@ TEST_F(LoggerTest, LoggerNameLength) {
#endif
}
+TEST_F(LoggerTest, setInterprocessSync) {
+ // Create a logger
+ Logger logger("alpha");
+
+ EXPECT_THROW(logger.setInterprocessSync(NULL), BadInterprocessSync);
+}
+
class MockSync : public isc::util::InterprocessSync {
public:
/// \brief Constructor
More information about the bind10-changes
mailing list