Parcourir la source

[2282] allow getAbsoluteLabels() to use the node's labelseq if it's absolute.

this will help the case where it's the zone origin.  the additional
handling often needs the origin's label sequence.
JINMEI Tatuya il y a 12 ans
Parent
commit
00bbd50bb7
1 fichiers modifiés avec 11 ajouts et 1 suppressions
  1. 11 1
      src/lib/datasrc/memory/domaintree.h

+ 11 - 1
src/lib/datasrc/memory/domaintree.h

@@ -593,7 +593,17 @@ isc::dns::LabelSequence
 DomainTreeNode<T>::getAbsoluteLabels(
     uint8_t buf[isc::dns::LabelSequence::MAX_SERIALIZED_LENGTH]) const
 {
-    isc::dns::LabelSequence result(getLabels(), buf);
+    // If the current node already has absolute labels, just return it.
+    // This should normally be the case for the origin node if this tree
+    // is used to represent a single DNS zone.
+    const isc::dns::LabelSequence cur_labels(getLabels());
+    if (cur_labels.isAbsolute()) {
+        return (cur_labels);
+    }
+
+    // Otherwise, build the absolute sequence traversing the tree of tree
+    // toward the top root.
+    isc::dns::LabelSequence result(cur_labels, buf);
     const DomainTreeNode<T>* upper = getUpperNode();
     while (upper != NULL) {
         result.extend(upper->getLabels(), buf);