|
@@ -24,6 +24,54 @@ namespace isc {
|
|
|
namespace datasrc {
|
|
|
namespace memory {
|
|
|
|
|
|
+namespace { // anonymous namespace
|
|
|
+
|
|
|
+// Returns a value-less than, or greater-than zero if 'a' is less-than
|
|
|
+// or greater-than 'b'. If they are equal, it returns 0. The comparison
|
|
|
+// function is such that often-used types such as A, AAAA, NS, SOA, MX,
|
|
|
+// etc. are less than other types. See the code for the ordering.
|
|
|
+int
|
|
|
+compareTypes(const RdataSet* a,
|
|
|
+ const RdataSet* b) {
|
|
|
+ // First RRType::A()
|
|
|
+ if (a->type == RRType::A()) {
|
|
|
+ return (-1);
|
|
|
+ } else if (b->type == RRType::A()) {
|
|
|
+ return (1);
|
|
|
+ }
|
|
|
+
|
|
|
+ // Then, RRType::AAAA(), etc.
|
|
|
+ if (a->type == RRType::AAAA()) {
|
|
|
+ return (-1);
|
|
|
+ } else if (b->type == RRType::AAAA()) {
|
|
|
+ return (1);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (a->type == RRType::NS()) {
|
|
|
+ return (-1);
|
|
|
+ } else if (b->type == RRType::NS()) {
|
|
|
+ return (1);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (a->type == RRType::SOA()) {
|
|
|
+ return (-1);
|
|
|
+ } else if (b->type == RRType::SOA()) {
|
|
|
+ return (1);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (a->type == RRType::MX()) {
|
|
|
+ return (-1);
|
|
|
+ } else if (b->type == RRType::MX()) {
|
|
|
+ return (1);
|
|
|
+ }
|
|
|
+
|
|
|
+ // Everything else comes in front of the rest of the list, so that
|
|
|
+ // we can insert quickly.
|
|
|
+ return (-1);
|
|
|
+}
|
|
|
+
|
|
|
+} // end of anonymous namespace
|
|
|
+
|
|
|
void
|
|
|
ZoneDataUpdater::addWildcards(const Name& name) {
|
|
|
Name wname(name);
|
|
@@ -249,12 +297,29 @@ ZoneDataUpdater::addRdataSet(const ConstRRsetPtr rrset,
|
|
|
<< rrset->getType() << ")");
|
|
|
}
|
|
|
|
|
|
- RdataSet* rdataset = RdataSet::create(mem_sgmt_, encoder_,
|
|
|
- rrset, rrsig);
|
|
|
- rdataset->next = rdataset_head;
|
|
|
- node->setData(rdataset);
|
|
|
+ RdataSet* rdataset_new = RdataSet::create(mem_sgmt_, encoder_,
|
|
|
+ rrset, rrsig);
|
|
|
+
|
|
|
+ // Insertion sort the new RdataSet into place in the list.
|
|
|
+ RdataSet* prev = NULL;
|
|
|
+ RdataSet* current = rdataset_head;
|
|
|
+ for (; current != NULL; current = current->getNext())
|
|
|
+ {
|
|
|
+ if (compareTypes(rdataset_new, current) < 0) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ prev = current;
|
|
|
+ }
|
|
|
+
|
|
|
+ rdataset_new->next = current;
|
|
|
+ if (prev != NULL) {
|
|
|
+ prev->next = rdataset_new;
|
|
|
+ } else {
|
|
|
+ node->setData(rdataset_new);
|
|
|
+ }
|
|
|
|
|
|
- // Ok, we just put it in
|
|
|
+ // Ok, we just put it in.
|
|
|
|
|
|
// If this RRset creates a zone cut at this node, mark the node
|
|
|
// indicating the need for callback in find().
|