Browse Source

[2108] Port addWildcards() to the new design

Mukund Sivaraman 12 years ago
parent
commit
bba5b86a7c
1 changed files with 12 additions and 16 deletions
  1. 12 16
      src/lib/datasrc/memory/memory_client.cc

+ 12 - 16
src/lib/datasrc/memory/memory_client.cc

@@ -125,7 +125,7 @@ public:
     // Add the necessary magic for any wildcard contained in 'name'
     // Add the necessary magic for any wildcard contained in 'name'
     // (including itself) to be found in the zone.
     // (including itself) to be found in the zone.
     //
     //
-    // In order for wildcard matching to work correctly in find(),
+    // In order for wildcard matching to work correctly in the zone finder,
     // we must ensure that a node for the wildcarding level exists in the
     // we must ensure that a node for the wildcarding level exists in the
     // backend RBTree.
     // backend RBTree.
     // E.g. if the wildcard name is "*.sub.example." then we must ensure
     // E.g. if the wildcard name is "*.sub.example." then we must ensure
@@ -135,35 +135,32 @@ public:
     //
     //
     // We also perform the same trick for empty wild card names possibly
     // We also perform the same trick for empty wild card names possibly
     // contained in 'name' (e.g., '*.foo.example' in 'bar.*.foo.example').
     // contained in 'name' (e.g., '*.foo.example' in 'bar.*.foo.example').
-    void addWildcards(util::MemorySegment& mem_sgmt, ZoneTree& domains,
-                      const Name& name)
+    void addWildcards(const Name& zone_name, const Name& name)
     {
     {
         Name wname(name);
         Name wname(name);
         const unsigned int labels(wname.getLabelCount());
         const unsigned int labels(wname.getLabelCount());
-        const unsigned int origin_labels(origin_.getLabelCount());
+        const unsigned int origin_labels(zone_name.getLabelCount());
         for (unsigned int l = labels;
         for (unsigned int l = labels;
              l > origin_labels;
              l > origin_labels;
              --l, wname = wname.split(1)) {
              --l, wname = wname.split(1)) {
             if (wname.isWildcard()) {
             if (wname.isWildcard()) {
                 LOG_DEBUG(logger, DBG_TRACE_DATA, DATASRC_MEM_ADD_WILDCARD).
                 LOG_DEBUG(logger, DBG_TRACE_DATA, DATASRC_MEM_ADD_WILDCARD).
                     arg(name);
                     arg(name);
+
+                ZoneNode *node;
+
                 // Ensure a separate level exists for the "wildcarding" name,
                 // Ensure a separate level exists for the "wildcarding" name,
                 // and mark the node as "wild".
                 // and mark the node as "wild".
-                DomainNode* node;
-                DomainTree::Result result(domains.insert(mem_sgmt,
-                                                         wname.split(1),
-                                                         &node));
-                assert(result == DomainTree::SUCCESS ||
-                       result == DomainTree::ALREADYEXISTS);
-                node->setFlag(domain_flag::WILD);
+                ZoneTree::Result result(zone_data_->insertName(local_mem_sgmt,
+                                                               wname.split(1),
+                                                               &node));
+                node->setFlag(ZoneData::WILDCARD_NODE);
 
 
                 // Ensure a separate level exists for the wildcard name.
                 // Ensure a separate level exists for the wildcard name.
                 // Note: for 'name' itself we do this later anyway, but the
                 // Note: for 'name' itself we do this later anyway, but the
                 // overhead should be marginal because wildcard names should
                 // overhead should be marginal because wildcard names should
                 // be rare.
                 // be rare.
-                result = domains.insert(mem_sgmt, wname, &node);
-                assert(result == DomainTree::SUCCESS ||
-                       result == DomainTree::ALREADYEXISTS);
+                result = zone_data_->insertName(local_mem_sgmt, wname, &node);
             }
             }
         }
         }
     }
     }
@@ -461,8 +458,7 @@ public:
         // tree.
         // tree.
         // Note: this can throw an exception, breaking strong exception
         // Note: this can throw an exception, breaking strong exception
         // guarantee.  (see also the note for contextCheck() below).
         // guarantee.  (see also the note for contextCheck() below).
-        addWildcards(zone_data.local_mem_sgmt_, zone_data.domains_,
-                     rrset->getName());
+        addWildcards(zone_name, rrset->getName());
 
 
         // Get the node
         // Get the node
         DomainNode* node;
         DomainNode* node;