Commit 56afaa4d authored by Mukund Sivaraman's avatar Mukund Sivaraman
Browse files

[2108] Changed proto of ZoneTable::setZoneData() to return a FindResult

This is so we can differentiate between whether a node was not found
and whether a node was found, but its old data was empty.

We also don't set the node data now when an exact match was not found.
Before it used to set for partial matches too (which was a bug).
parent e3f72ac2
......@@ -620,9 +620,11 @@ InMemoryClient::InMemoryClientImpl::load(
++zone_count_;
}
ZoneData *data = zone_table_->setZoneData(zone_name, holder.release());
if (data != NULL) {
ZoneData::destroy(local_mem_sgmt_, data, rrclass_);
ZoneTable::FindResult fr(zone_table_->setZoneData(zone_name,
holder.release()));
assert(fr.code == result::SUCCESS);
if (fr.zone_data != NULL) {
ZoneData::destroy(local_mem_sgmt_, fr.zone_data, rrclass_);
}
return (result.code);
......
......@@ -132,19 +132,18 @@ ZoneTable::findZone(const Name& name) const {
return (FindResult(my_result, node->getData()));
}
ZoneData*
ZoneTable::FindResult
ZoneTable::setZoneData(const Name& name, ZoneData* data)
{
ZoneTableNode* node(NULL);
ZoneTableTree::Result result(zones_->find(name, &node));
if ((result != ZoneTableTree::EXACTMATCH) &&
(result != ZoneTableTree::PARTIALMATCH)) {
return (NULL);
if (result != ZoneTableTree::EXACTMATCH) {
return (FindResult(result::NOTFOUND, NULL));
} else {
return (FindResult(result::SUCCESS, node->setData(data)));
}
return (node->setData(data));
}
} // end of namespace memory
......
......@@ -191,9 +191,9 @@ public:
///
/// \param name A domain name for which the zone data is set.
/// \param data The new zone data to set.
/// \return A \c ZoneData object containing the old data if the zone
/// was found, or \c NULL otherwise.
ZoneData* setZoneData(const isc::dns::Name& name, ZoneData* data);
/// \return A \c FindResult object containing the old data if the
/// zone was found.
FindResult setZoneData(const isc::dns::Name& name, ZoneData* data);
private:
boost::interprocess::offset_ptr<ZoneTableTree> zones_;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment