BIND 10 trac1069, updated. ac06e0bbad2fd39f8cc77fac06fc397be14f92c2 [trac1069] throw an exception when getSockAddr fails (which shouldn't happen) instead of returning a dummy structure, expecting it to cause a subsequent failure.

BIND 10 source code commits bind10-changes at lists.isc.org
Fri Jul 1 17:47:28 UTC 2011


The branch, trac1069 has been updated
       via  ac06e0bbad2fd39f8cc77fac06fc397be14f92c2 (commit)
       via  a6de7efe8fbf314c5182744d462699283464d9f0 (commit)
       via  3bd81bcaed4c9c2ca6c6ed5fab00f350be5c2eef (commit)
      from  d2dc7a3ef911a5ab83527753f351bc99440d60fe (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 ac06e0bbad2fd39f8cc77fac06fc397be14f92c2
Author: JINMEI Tatuya <jinmei at isc.org>
Date:   Fri Jul 1 10:43:25 2011 -0700

    [trac1069] throw an exception when getSockAddr fails (which shouldn't happen)
    instead of returning a dummy structure, expecting it to cause a subsequent
    failure.

commit a6de7efe8fbf314c5182744d462699283464d9f0
Author: JINMEI Tatuya <jinmei at isc.org>
Date:   Fri Jul 1 10:32:02 2011 -0700

    [trac1069] grammar fix in the doc (although it's not introdued in
    this branch)

commit 3bd81bcaed4c9c2ca6c6ed5fab00f350be5c2eef
Author: JINMEI Tatuya <jinmei at isc.org>
Date:   Fri Jul 1 10:30:03 2011 -0700

    [trac1069] use isc::acl::dns::RequestACL directly instead of a separate
    typedef.  RequestACL is itself a shortcut, so it doesn't make sense to
    define another one.

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

Summary of changes:
 src/bin/resolver/resolver.cc                |   15 ++++++++-------
 src/bin/resolver/resolver.h                 |    8 +++-----
 src/bin/resolver/tests/resolver_unittest.cc |    4 ++--
 src/lib/acl/loader.h                        |    2 +-
 src/lib/acl/tests/sockaddr.h                |   15 +++++++++------
 5 files changed, 23 insertions(+), 21 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/resolver/resolver.cc b/src/bin/resolver/resolver.cc
index 1a481c2..75e3d52 100644
--- a/src/bin/resolver/resolver.cc
+++ b/src/bin/resolver/resolver.cc
@@ -62,6 +62,7 @@ using boost::shared_ptr;
 using namespace isc;
 using namespace isc::util;
 using namespace isc::acl;
+using isc::acl::dns::RequestACL;
 using namespace isc::dns;
 using namespace isc::data;
 using namespace isc::config;
@@ -162,11 +163,11 @@ public:
                                          OutputBufferPtr buffer,
                                          DNSServer* server);
 
-    const Resolver::QueryACL& getQueryACL() const {
+    const RequestACL& getQueryACL() const {
         return (*query_acl_);
     }
 
-    void setQueryACL(shared_ptr<const Resolver::QueryACL> new_acl) {
+    void setQueryACL(shared_ptr<const RequestACL> new_acl) {
         query_acl_ = new_acl;
     }
 
@@ -194,7 +195,7 @@ public:
 
 private:
     /// ACL on incoming queries
-    shared_ptr<const Resolver::QueryACL> query_acl_;
+    shared_ptr<const RequestACL> query_acl_;
 
     /// Object to handle upstream queries
     RecursiveQuery* rec_query_;
@@ -595,9 +596,9 @@ Resolver::updateConfig(ConstElementPtr config) {
         AddressList listenAddresses(parseAddresses(listenAddressesE,
                                                       "listen_on"));
         const ConstElementPtr query_acl_cfg(config->get("query_acl"));
-        const shared_ptr<const QueryACL> query_acl =
+        const shared_ptr<const RequestACL> query_acl =
             query_acl_cfg ? acl::dns::getLoader().load(query_acl_cfg) :
-            shared_ptr<const QueryACL>();
+            shared_ptr<const RequestACL>();
         bool set_timeouts(false);
         int qtimeout = impl_->query_timeout_;
         int ctimeout = impl_->client_timeout_;
@@ -757,13 +758,13 @@ Resolver::getListenAddresses() const {
     return (impl_->listen_);
 }
 
-const Resolver::QueryACL&
+const RequestACL&
 Resolver::getQueryACL() const {
     return (impl_->getQueryACL());
 }
 
 void
-Resolver::setQueryACL(shared_ptr<const QueryACL> new_acl) {
+Resolver::setQueryACL(shared_ptr<const RequestACL> new_acl) {
     if (!new_acl) {
         isc_throw(InvalidParameter, "NULL pointer is passed to setQueryACL");
     }
diff --git a/src/bin/resolver/resolver.h b/src/bin/resolver/resolver.h
index 656723d..4b9c773 100644
--- a/src/bin/resolver/resolver.h
+++ b/src/bin/resolver/resolver.h
@@ -239,13 +239,10 @@ public:
      */
     int getRetries() const;
 
-    // Shortcut typedef used for query ACL.
-    typedef isc::acl::ACL<isc::acl::dns::RequestContext> QueryACL;
-
     /// Get the query ACL.
     ///
     /// \exception None
-    const QueryACL& getQueryACL() const;
+    const isc::acl::dns::RequestACL& getQueryACL() const;
 
     /// Set the new query ACL.
     ///
@@ -258,7 +255,8 @@ public:
     /// \exception InvalidParameter The given pointer is NULL
     ///
     /// \param new_acl The new ACL to replace the existing one.
-    void setQueryACL(boost::shared_ptr<const QueryACL> new_acl);
+    void setQueryACL(boost::shared_ptr<const isc::acl::dns::RequestACL>
+                     new_acl);
 
 private:
     ResolverImpl* impl_;
diff --git a/src/bin/resolver/tests/resolver_unittest.cc b/src/bin/resolver/tests/resolver_unittest.cc
index 6eda442..71474dd 100644
--- a/src/bin/resolver/tests/resolver_unittest.cc
+++ b/src/bin/resolver/tests/resolver_unittest.cc
@@ -27,6 +27,7 @@
 using namespace std;
 using namespace isc::dns;
 using namespace isc::data;
+using isc::acl::dns::RequestACL;
 using namespace isc::testutils;
 using isc::UnitTestUtil;
 
@@ -156,8 +157,7 @@ TEST_F(ResolverTest, notifyFail) {
 TEST_F(ResolverTest, setQueryACL) {
     // valid cases are tested through other tests.  We only explicitly check
     // an invalid case: passing a NULL shared pointer.
-    EXPECT_THROW(server.setQueryACL(
-                     boost::shared_ptr<const Resolver::QueryACL>()),
+    EXPECT_THROW(server.setQueryACL(boost::shared_ptr<const RequestACL>()),
                  isc::InvalidParameter);
 }
 
diff --git a/src/lib/acl/loader.h b/src/lib/acl/loader.h
index ff9827b..a4b9b03 100644
--- a/src/lib/acl/loader.h
+++ b/src/lib/acl/loader.h
@@ -301,7 +301,7 @@ public:
      * and returns it.
      *
      * No exceptions from \c loadCheck (therefore from whatever creator is
-     * used) and from the actionLoader passed to constructor are not caught.
+     * used) and from the actionLoader passed to constructor are caught.
      *
      * \exception InvalidParameter The given element is NULL (most likely a
      * caller's bug)
diff --git a/src/lib/acl/tests/sockaddr.h b/src/lib/acl/tests/sockaddr.h
index 11d6387..bac1f6e 100644
--- a/src/lib/acl/tests/sockaddr.h
+++ b/src/lib/acl/tests/sockaddr.h
@@ -19,6 +19,8 @@
 #include <sys/socket.h>
 #include <netdb.h>
 
+#include <exceptions/exceptions.h>
+
 namespace isc {
 namespace acl {
 namespace tests {
@@ -35,7 +37,8 @@ inline const struct sockaddr&
 getSockAddr(const char* const addr) {
     struct addrinfo hints, *res;
     memset(&hints, 0, sizeof(hints));
-    hints.ai_family = AF_UNSPEC;
+    //hints.ai_family = AF_UNSPEC;
+    hints.ai_family = AF_INET;
     hints.ai_socktype = SOCK_STREAM;
     hints.ai_flags = AI_NUMERICHOST;
 
@@ -48,11 +51,11 @@ getSockAddr(const char* const addr) {
     }
 
     // We don't expect getaddrinfo to fail for our tests.  But if that
-    // ever happens we return a dummy value that would make subsequent test
-    // fail.
-    static struct sockaddr sa_dummy;
-    sa_dummy.sa_family = AF_UNSPEC;
-    return (sa_dummy);
+    // ever happens we throw an exception to make sure the corresponding test
+    // fail (either due to a failure of *_NO_THROW or the uncaught exception).
+    isc_throw(Unexpected,
+              "failed to convert textual IP address to sockaddr for " <<
+              addr);
 }
 
 } // end of namespace "tests"




More information about the bind10-changes mailing list