BIND 10 trac2376, updated. 75218acb5c5d42099f2ad3f4a0ea1dbb0f442016 [2384] Make the constructor protected

BIND 10 source code commits bind10-changes at lists.isc.org
Fri Nov 9 15:03:00 UTC 2012


The branch, trac2376 has been updated
       via  75218acb5c5d42099f2ad3f4a0ea1dbb0f442016 (commit)
       via  7e844e29b3386dad6ff90f42aa18668ba44573fc (commit)
       via  158523eddf5192a04c157da9eeb17e07e922dfee (commit)
      from  4ebfb41753e3c3489848dea372be3306c9e9e7a5 (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 75218acb5c5d42099f2ad3f4a0ea1dbb0f442016
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Fri Nov 9 16:02:45 2012 +0100

    [2384] Make the constructor protected
    
    It is enough.

commit 7e844e29b3386dad6ff90f42aa18668ba44573fc
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Fri Nov 9 15:54:15 2012 +0100

    [2384] Make logging of the context better
    
    Specify which zone it is and use filename:linenumber notation.

commit 158523eddf5192a04c157da9eeb17e07e922dfee
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Fri Nov 9 15:37:33 2012 +0100

    [2384] Documentation update

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

Summary of changes:
 src/lib/datasrc/datasrc_messages.mes         |    4 ++--
 src/lib/datasrc/loader_context.cc            |    9 ++++++---
 src/lib/datasrc/loader_context.h             |   23 +++++++++++++++++++++--
 src/lib/datasrc/tests/loader_context_test.cc |    6 +++---
 4 files changed, 32 insertions(+), 10 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/datasrc_messages.mes b/src/lib/datasrc/datasrc_messages.mes
index 9ba2d9c..cf086bf 100644
--- a/src/lib/datasrc/datasrc_messages.mes
+++ b/src/lib/datasrc/datasrc_messages.mes
@@ -305,14 +305,14 @@ Therefore, the zone will not be available for this process. If this is
 a problem, you should move the zone to some database backend (sqlite3, for
 example) and use it from there.
 
-% DATASRC_LOAD_CONTEXT_ERROR In master file '%1' on line '%2': '%3'
+% DATASRC_LOAD_CONTEXT_ERROR %1:%2: Zone '%3/%4' contains error: %5
 There's an error in the given master file. The zone won't be loaded for
 this reason. Parsing might follow, so you might get further errors and
 warnings to fix everything at once. But in case the error is serious enough,
 the parser might just give up or get confused and generate false errors
 afterwards.
 
-% DATASRC_LOAD_CONTEXT_WARN In master file '%1' on line '%2': '%3'
+% DATASRC_LOAD_CONTEXT_WARN %1:%2: Zone '%3/%4' has a potential problem: %5
 There's something suspicious in the master file. This is a warning only.
 It may be a problem or it may be harmless, but it should be checked.
 This problem does not stop the zone from being loaded.
diff --git a/src/lib/datasrc/loader_context.cc b/src/lib/datasrc/loader_context.cc
index 21c4d48..ec4329c 100644
--- a/src/lib/datasrc/loader_context.cc
+++ b/src/lib/datasrc/loader_context.cc
@@ -21,10 +21,13 @@
 namespace isc {
 namespace datasrc {
 
-LoaderContext::LoaderContext(ZoneUpdater& updater) :
+LoaderContext::LoaderContext(ZoneUpdater& updater, const dns::Name& name,
+                             const dns::RRClass& rrclass) :
     callbacks_(boost::bind(&LoaderContext::handleError, this, _1, _2, _3, _4),
                boost::bind(&LoaderContext::handleWarning, this, _1, _2, _3,
                            _4)),
+    name_(name),
+    rrclass_(rrclass),
     updater_(updater),
     ok_(true)
 {
@@ -40,7 +43,7 @@ LoaderContext::handleWarning(const std::string& source, size_t line, size_t,
                              const std::string& reason)
 {
     LOG_WARN(logger, DATASRC_LOAD_CONTEXT_WARN).arg(source).arg(line).
-        arg(reason);
+        arg(name_).arg(rrclass_).arg(reason);
 }
 
 void
@@ -48,7 +51,7 @@ LoaderContext::handleError(const std::string& source, size_t line, size_t,
                            const std::string& reason)
 {
     LOG_ERROR(logger, DATASRC_LOAD_CONTEXT_ERROR).arg(source).arg(line).
-        arg(reason);
+        arg(name_).arg(rrclass_).arg(line).arg(reason);
     ok_ = false;
 }
 
diff --git a/src/lib/datasrc/loader_context.h b/src/lib/datasrc/loader_context.h
index ef1200e..1f58f3f 100644
--- a/src/lib/datasrc/loader_context.h
+++ b/src/lib/datasrc/loader_context.h
@@ -16,6 +16,8 @@
 #define DATASRC_LOADER_CONTEXT
 
 #include <dns/master_loader.h>
+#include <dns/name.h>
+#include <dns/rrclass.h>
 
 #include <boost/noncopyable.hpp>
 
@@ -38,13 +40,22 @@ public:
     ///
     /// \param updater The zone updater to use. It should be a clean updater
     ///     (no changes done to it yet). It is up to the caller to commit or
-    ///     rollback the updater after the loading is done.
-    LoaderContext(ZoneUpdater& updater);
+    ///     rollback the updater after the loading is done. It should be
+    ///     created in the replace mode, but it is not checked.
+    /// \param name The zone name. Used in logging.
+    /// \param rrclass The class of the zone. Used in logging.
+    /// \throw std::bad_alloc If allocation fails.
+    LoaderContext(ZoneUpdater& updater, const dns::Name& name,
+                  const dns::RRClass& rrclass);
 
     /// \brief Adds a new rrset to the updater.
     ///
     /// This is implementation of the interface's method.
     ///
+    /// Since it is just a thin wrapper around the
+    /// ZoneUpdater::addRRset, it does not throw any exception itself.
+    /// But it passes all exceptions from the updater.
+    ///
     /// \param rrset The rrset to add.
     virtual void addRRset(const isc::dns::RRsetPtr& rrset);
 
@@ -52,6 +63,8 @@ public:
     ///
     /// This is implementation of the interface's method.
     ///
+    /// It never throws.
+    ///
     /// \return Structure holding the callbacks that can be used to report
     ///     errors.
     virtual isc::dns::LoaderCallbacks& getCallbacks() {
@@ -60,6 +73,8 @@ public:
 
     /// \brief Was the load successful?
     ///
+    /// It never throws.
+    ///
     /// \return True if the load was successful so far - which means no
     ///     getCallbacks().error() was called yet. False otherwise.
     bool ok() const {
@@ -83,6 +98,10 @@ private:
     /// the actual callbacks (the operator() might be non-const).
     isc::dns::LoaderCallbacks callbacks_;
 
+    // Identification of the zone, used in logging.
+    isc::dns::Name name_;
+    isc::dns::RRClass rrclass_;
+
     /// \brief The updater to be used.
     ZoneUpdater& updater_;
 
diff --git a/src/lib/datasrc/tests/loader_context_test.cc b/src/lib/datasrc/tests/loader_context_test.cc
index 7166dfb..8ed9966 100644
--- a/src/lib/datasrc/tests/loader_context_test.cc
+++ b/src/lib/datasrc/tests/loader_context_test.cc
@@ -60,11 +60,11 @@ public:
 };
 
 class LoaderContextTest : public ::testing::Test {
-public:
+protected:
     LoaderContextTest() :
-        context_(updater_)
+        context_(updater_, isc::dns::Name("example.org"),
+                 isc::dns::RRClass::IN())
     {}
-protected:
     // Generate a new RRset, put it to the updater and return it.
     isc::dns::RRsetPtr generateRRset() {
         const isc::dns::RRsetPtr



More information about the bind10-changes mailing list