Browse Source

[trac534] Check for origin by pointer, not name

Michal 'vorner' Vaner 14 years ago
parent
commit
eb4c790522
1 changed files with 12 additions and 7 deletions
  1. 12 7
      src/lib/datasrc/memory_datasrc.cc

+ 12 - 7
src/lib/datasrc/memory_datasrc.cc

@@ -35,14 +35,9 @@ namespace datasrc {
 struct MemoryZone::MemoryZoneImpl {
 struct MemoryZone::MemoryZoneImpl {
     // Constructor
     // Constructor
     MemoryZoneImpl(const RRClass& zone_class, const Name& origin) :
     MemoryZoneImpl(const RRClass& zone_class, const Name& origin) :
-        zone_class_(zone_class), origin_(origin)
+        zone_class_(zone_class), origin_(origin), origin_data_(NULL)
     {}
     {}
 
 
-    // Information about the zone
-    RRClass zone_class_;
-    Name origin_;
-    string file_name_;
-
     // Some type aliases
     // Some type aliases
     /*
     /*
      * Each domain consists of some RRsets. They will be looked up by the
      * Each domain consists of some RRsets. They will be looked up by the
@@ -61,6 +56,13 @@ struct MemoryZone::MemoryZoneImpl {
     // The tree stores domains
     // The tree stores domains
     typedef RBTree<Domain> DomainTree;
     typedef RBTree<Domain> DomainTree;
     typedef RBNode<Domain> DomainNode;
     typedef RBNode<Domain> DomainNode;
+
+    // Information about the zone
+    RRClass zone_class_;
+    Name origin_;
+    DomainNode* origin_data_;
+    string file_name_;
+
     // The actual zone data
     // The actual zone data
     DomainTree domains_;
     DomainTree domains_;
 
 
@@ -112,6 +114,9 @@ struct MemoryZone::MemoryZoneImpl {
         if (node->isEmpty()) {
         if (node->isEmpty()) {
             domain.reset(new Domain);
             domain.reset(new Domain);
             node->setData(domain);
             node->setData(domain);
+            if (origin_data_ == NULL && name == origin_) {
+                origin_data_ = node;
+            }
         } else { // Get existing one
         } else { // Get existing one
             domain = node->getData();
             domain = node->getData();
         }
         }
@@ -296,7 +301,7 @@ struct MemoryZone::MemoryZoneImpl {
 
 
         // If the node callback is enabled, this may be a zone cut.  If it
         // If the node callback is enabled, this may be a zone cut.  If it
         // has a NS RR, we should return a delegation, but not in the apex.
         // has a NS RR, we should return a delegation, but not in the apex.
-        if (node->isCallbackEnabled() && node->getName() != origin_) {
+        if (node->isCallbackEnabled() && node != origin_data_) {
             found = node->getData()->find(RRType::NS());
             found = node->getData()->find(RRType::NS());
             if (found != node->getData()->end()) {
             if (found != node->getData()->end()) {
                 return (FindResult(DELEGATION, found->second));
                 return (FindResult(DELEGATION, found->second));