]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[1579] suggested change: pass a reference of ZoneFinder to DNSSECContext.
authorJINMEI Tatuya <jinmei@isc.org>
Thu, 12 Apr 2012 18:50:05 +0000 (11:50 -0700)
committerJINMEI Tatuya <jinmei@isc.org>
Thu, 12 Apr 2012 18:50:05 +0000 (11:50 -0700)
instead of a pointer.
IMO, finderp_ should better be a reference than a pointer if we'd
worry about the case where it's NULL later on, like getNSECRRset
does (which shouldn't never happen in our usage).
the NULL pointer check was therefore removed with this change.

src/lib/datasrc/database.cc
src/lib/datasrc/database.h

index 0e7b3cd5f534dfe2fd6b9aacb707f3407e97ac6f..fd9cf350db791e293cdb098940ebce636e89397d 100644 (file)
@@ -712,9 +712,9 @@ DatabaseClient::Finder::logAndCreateResult(
 }
 
 DatabaseClient::Finder::FindDNSSECContext::FindDNSSECContext(
-    DatabaseClient::Finder* finderp,
+    DatabaseClient::Finder& finder,
     const FindOptions options) :
-    finderp_(finderp),
+    finder_(finder),
     need_dnssec_((options & FIND_DNSSEC) != 0),
     is_nsec3_(false),
     is_nsec_(false),
@@ -723,18 +723,15 @@ DatabaseClient::Finder::FindDNSSECContext::FindDNSSECContext(
 
 void
 DatabaseClient::Finder::FindDNSSECContext::init() {
-    if (finderp_ == NULL) {
-        isc_throw(DataSourceError, "no Finder to query");
-    }
     if (!initialized_) {
         initialized_ = true;
         if (need_dnssec_) {
             // If NSEC3PARAM rrset exists, the zone looks like signed with
             // NSEC3
-            is_nsec3_ = finderp_->isNSEC3();
+            is_nsec3_ = finder_.isNSEC3();
             // If no NSEC3PARAM and it is DNSSEC query, check whether NSEC
             // exist in apex of zone
-            is_nsec_ = is_nsec3_ ? false : finderp_->isNSEC();
+            is_nsec_ = is_nsec3_ ? false : finder_.isNSEC();
         }
     }
 }
@@ -779,11 +776,8 @@ DatabaseClient::Finder::FindDNSSECContext::getNSECRRset(
 isc::dns::ConstRRsetPtr
 DatabaseClient::Finder::FindDNSSECContext::getNSECRRset(const Name &name) const
 {
-    if (finderp_ == NULL) {
-        isc_throw(DataSourceError, "no Finder to query");
-    }
-    const FoundRRsets wfound = finderp_->getRRsets(name.toText(), NSEC_TYPES(),
-                                                   true);
+    const FoundRRsets wfound = finder_.getRRsets(name.toText(), NSEC_TYPES(),
+                                                 true);
     const FoundIterator nci = wfound.second.find(RRType::NSEC());
     if (nci != wfound.second.end()) {
         return (nci->second);
@@ -1035,7 +1029,7 @@ DatabaseClient::Finder::findInternal(const Name& name, const RRType& type,
     const FoundRRsets found = getRRsets(name.toText(), final_types,
                                         !is_origin, NULL,
                                         type == RRType::ANY());
-    FindDNSSECContext dnssec_ctx(this, options);
+    FindDNSSECContext dnssec_ctx(*this, options);
     if (found.first) {
         // Something found at the domain name.  Look into it further to get
         // the final result.
index c78fb821fbdfde3bf16e5a1a791c9e31097884f4..a42a4a41c940e36b3a6456ba69d3194af7ae861d 100644 (file)
@@ -867,7 +867,7 @@ public:
             ///
             /// \param finderp The Finder piont for search.
             /// \param options Search options.
-            FindDNSSECContext(Finder* finderp, const FindOptions options);
+            FindDNSSECContext(Finder& finder, const FindOptions options);
 
             /// \brief Get result flags of this query.
             /// \return ResultFlags for this query. If the zone file is
@@ -930,7 +930,7 @@ public:
             /// \return True for inited, else return false.
             bool isInited();
 
-            DatabaseClient::Finder* const finderp_;
+            DatabaseClient::Finder& finder_;
             const bool need_dnssec_;
 
             FindResultFlags flags_;