BIND 10 master, updated. 5da8f8131b1224c99603852e1574b2a1adace236 [master] Merge branch 'trac1622'

BIND 10 source code commits bind10-changes at lists.isc.org
Mon Jun 3 19:57:27 UTC 2013


The branch, master has been updated
       via  5da8f8131b1224c99603852e1574b2a1adace236 (commit)
       via  71007940646f888480f85dc2780c0d600f64d179 (commit)
       via  439ab563402b77e745db3181af1751ebcac519f3 (commit)
       via  c1ca91c677addbb7a546ea8e36cc67e0717f1fb7 (commit)
       via  cab5acfd0cd42260988424e06d926d22e37e1e11 (commit)
       via  d4389a32b03dafe3c369e9d10d0001687ec74f55 (commit)
      from  156c5f32bb38cdb94361726fe4f0d40adf39bbdd (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 5da8f8131b1224c99603852e1574b2a1adace236
Merge: 156c5f3 7100794
Author: JINMEI Tatuya <jinmei at isc.org>
Date:   Mon Jun 3 12:53:45 2013 -0700

    [master] Merge branch 'trac1622'

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

Summary of changes:
 doc/guide/bind10-guide.xml                   |   17 +++++++++++++++++
 src/lib/log/logger_manager_impl.cc           |   23 +++++++++++++++++++----
 src/lib/log/tests/Makefile.am                |    2 +-
 src/lib/log/tests/logger_manager_unittest.cc |    6 +++++-
 4 files changed, 42 insertions(+), 6 deletions(-)

-----------------------------------------------------------------------
diff --git a/doc/guide/bind10-guide.xml b/doc/guide/bind10-guide.xml
index 5924f70..9d1986d 100644
--- a/doc/guide/bind10-guide.xml
+++ b/doc/guide/bind10-guide.xml
@@ -5567,6 +5567,23 @@ TODO; there's a ticket to determine these levels, see #1074
             If this is 0, no maximum file size is used.
           </para>
 
+          <note>
+            <simpara>
+	      Due to a limitation of the underlying logging library
+	      (log4cplus), rolling over the log files (from ".1" to
+	      ".2", etc) may show odd results: There can be
+	      multiple small files at the timing of roll over.  This
+	      can happen when multiple BIND 10 processes try to roll
+	      over the files simultaneously.
+	      Version 1.1.0 of log4cplus solved this problem, so if
+	      this or higher version of log4cplus is used to build
+	      BIND 10, it shouldn't happen.  Even for older versions
+	      it is normally expected to happen rarely unless the log
+	      messages are produced very frequently by multiple
+	      different processes.
+	    </simpara>
+	  </note>
+
         </section>
 
         <section>
diff --git a/src/lib/log/logger_manager_impl.cc b/src/lib/log/logger_manager_impl.cc
index 711eae9..9fb4d57 100644
--- a/src/lib/log/logger_manager_impl.cc
+++ b/src/lib/log/logger_manager_impl.cc
@@ -35,7 +35,10 @@
 #include <log/logger_specification.h>
 #include <log/buffer_appender_impl.h>
 
+#include <boost/lexical_cast.hpp>
+
 using namespace std;
+using boost::lexical_cast;
 
 namespace isc {
 namespace log {
@@ -121,21 +124,33 @@ LoggerManagerImpl::createConsoleAppender(log4cplus::Logger& logger,
 
 // File appender.  Depending on whether a maximum size is given, either
 // a standard file appender or a rolling file appender will be created.
+// In the case of the latter, we set "UseLockFile" to true so that
+// log4cplus internally avoids race in rolling over the files by multiple
+// processes.  This feature isn't supported in log4cplus 1.0.x, but setting
+// the property unconditionally is okay as unknown properties are simply
+// ignored.
 void
 LoggerManagerImpl::createFileAppender(log4cplus::Logger& logger,
-                                         const OutputOption& opt)
+                                      const OutputOption& opt)
 {
     // Append to existing file
-    std::ios::openmode mode = std::ios::app;
+    const std::ios::openmode mode = std::ios::app;
 
     log4cplus::SharedAppenderPtr fileapp;
     if (opt.maxsize == 0) {
         fileapp = log4cplus::SharedAppenderPtr(new log4cplus::FileAppender(
             opt.filename, mode, opt.flush));
     } else {
+        log4cplus::helpers::Properties properties;
+        properties.setProperty("File", opt.filename);
+        properties.setProperty("MaxFileSize",
+                               lexical_cast<string>(opt.maxsize));
+        properties.setProperty("MaxBackupIndex",
+                               lexical_cast<string>(opt.maxver));
+        properties.setProperty("ImmediateFlush", opt.flush ? "true" : "false");
+        properties.setProperty("UseLockFile", "true");
         fileapp = log4cplus::SharedAppenderPtr(
-            new log4cplus::RollingFileAppender(opt.filename, opt.maxsize,
-                                               opt.maxver, opt.flush));
+            new log4cplus::RollingFileAppender(properties));
     }
 
     // use the same console layout for the files.
diff --git a/src/lib/log/tests/Makefile.am b/src/lib/log/tests/Makefile.am
index 36582e6..92303e0 100644
--- a/src/lib/log/tests/Makefile.am
+++ b/src/lib/log/tests/Makefile.am
@@ -10,7 +10,7 @@ if USE_STATIC_LINK
 AM_LDFLAGS += -static
 endif
 
-CLEANFILES = *.gcno *.gcda
+CLEANFILES = *.gcno *.gcda *.lock
 
 EXTRA_DIST = log_test_messages.mes
 BUILT_SOURCES = log_test_messages.h log_test_messages.cc
diff --git a/src/lib/log/tests/logger_manager_unittest.cc b/src/lib/log/tests/logger_manager_unittest.cc
index 584d0f5..e615c41 100644
--- a/src/lib/log/tests/logger_manager_unittest.cc
+++ b/src/lib/log/tests/logger_manager_unittest.cc
@@ -77,7 +77,11 @@ public:
     // Destructor, remove the file.  This is only a test, so ignore failures
     ~SpecificationForFileLogger() {
         if (! name_.empty()) {
-            (void) unlink(name_.c_str());
+            static_cast<void>(unlink(name_.c_str()));
+
+            // Depending on the log4cplus version, a lock file may also be
+            // created.
+            static_cast<void>(unlink((name_ + ".lock").c_str()));
         }
     }
 



More information about the bind10-changes mailing list