mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-09-01 06:25:34 +00:00
[1791] more cleanup: remove variable 'rdata' and make it a member variable.
this way we can also avoid creating the same RDATA twice. textual row variables were renamed to *_txt_ for consistency.
This commit is contained in:
@@ -1008,15 +1008,18 @@ public:
|
|||||||
LOG_DEBUG(logger, DBG_TRACE_DETAILED, DATASRC_DATABASE_ITERATE_END);
|
LOG_DEBUG(logger, DBG_TRACE_DETAILED, DATASRC_DATABASE_ITERATE_END);
|
||||||
return (ConstRRsetPtr());
|
return (ConstRRsetPtr());
|
||||||
}
|
}
|
||||||
const Name name(name_);
|
const RRType rtype(rtype_txt_);
|
||||||
const RRType rtype(rtype_);
|
RRsetPtr rrset(new RRset(Name(name_txt_), class_, rtype,
|
||||||
RRsetPtr rrset(new RRset(name, class_, rtype, RRTTL(ttl_)));
|
RRTTL(ttl_txt_)));
|
||||||
const ConstRdataPtr rdata_base =
|
// For the first RR, rdata_ is null, so we need to create it here.
|
||||||
rdata::createRdata(rtype, class_, rdata_);
|
// After that, rdata_ will be updated in the while loop below.
|
||||||
ConstRdataPtr rdata = rdata_base;
|
if (!rdata_) {
|
||||||
|
rdata_ = rdata::createRdata(rtype, class_, rdata_txt_);
|
||||||
|
}
|
||||||
|
const ConstRdataPtr rdata_base = rdata_; // remember it for comparison
|
||||||
while (true) {
|
while (true) {
|
||||||
// Extend the RRset with the new RDATA.
|
// Extend the RRset with the new RDATA.
|
||||||
rrset->addRdata(rdata);
|
rrset->addRdata(rdata_);
|
||||||
|
|
||||||
// Retrieve the next record from the database. If we reach the
|
// Retrieve the next record from the database. If we reach the
|
||||||
// end of the zone, done; if we were requested to separate all RRs,
|
// end of the zone, done; if we were requested to separate all RRs,
|
||||||
@@ -1027,22 +1030,24 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if the next record belongs to the same RRset. If not,
|
// Check if the next record belongs to the same RRset. If not,
|
||||||
// we are done.
|
// we are done. The next RDATA is stored in rdata_, which is used
|
||||||
const RRType next_rtype(rtype_);
|
// within this loop (if it belongs to the same RRset) or in the
|
||||||
rdata = rdata::createRdata(next_rtype, class_, rdata_);
|
// next call.
|
||||||
if (Name(name_) != name ||
|
const RRType next_rtype(rtype_txt_);
|
||||||
!isSameType(rtype, rdata_base, next_rtype, rdata)) {
|
rdata_ = rdata::createRdata(next_rtype, class_, rdata_txt_);
|
||||||
|
if (Name(name_txt_) != rrset->getName() ||
|
||||||
|
!isSameType(rtype, rdata_base, next_rtype, rdata_)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adjust TTL if necessary
|
// Adjust TTL if necessary
|
||||||
const RRTTL next_ttl(ttl_);
|
const RRTTL next_ttl(ttl_txt_);
|
||||||
if (next_ttl != rrset->getTTL()) {
|
if (next_ttl != rrset->getTTL()) {
|
||||||
if (next_ttl < rrset->getTTL()) {
|
if (next_ttl < rrset->getTTL()) {
|
||||||
rrset->setTTL(next_ttl);
|
rrset->setTTL(next_ttl);
|
||||||
}
|
}
|
||||||
LOG_WARN(logger, DATASRC_DATABASE_ITERATE_TTL_MISMATCH).
|
LOG_WARN(logger, DATASRC_DATABASE_ITERATE_TTL_MISMATCH).
|
||||||
arg(name_).arg(class_).arg(rtype_).arg(rrset->getTTL());
|
arg(name_txt_).arg(class_).arg(rtype).arg(rrset->getTTL());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LOG_DEBUG(logger, DBG_TRACE_DETAILED, DATASRC_DATABASE_ITERATE_NEXT).
|
LOG_DEBUG(logger, DBG_TRACE_DETAILED, DATASRC_DATABASE_ITERATE_NEXT).
|
||||||
@@ -1072,10 +1077,10 @@ private:
|
|||||||
void getData() {
|
void getData() {
|
||||||
string data[DatabaseAccessor::COLUMN_COUNT];
|
string data[DatabaseAccessor::COLUMN_COUNT];
|
||||||
data_ready_ = context_->getNext(data);
|
data_ready_ = context_->getNext(data);
|
||||||
name_ = data[DatabaseAccessor::NAME_COLUMN];
|
name_txt_ = data[DatabaseAccessor::NAME_COLUMN];
|
||||||
rtype_ = data[DatabaseAccessor::TYPE_COLUMN];
|
rtype_txt_ = data[DatabaseAccessor::TYPE_COLUMN];
|
||||||
ttl_ = data[DatabaseAccessor::TTL_COLUMN];
|
ttl_txt_ = data[DatabaseAccessor::TTL_COLUMN];
|
||||||
rdata_ = data[DatabaseAccessor::RDATA_COLUMN];
|
rdata_txt_= data[DatabaseAccessor::RDATA_COLUMN];
|
||||||
}
|
}
|
||||||
|
|
||||||
// The dedicated accessor
|
// The dedicated accessor
|
||||||
@@ -1089,7 +1094,9 @@ private:
|
|||||||
// Status
|
// Status
|
||||||
bool ready_, data_ready_;
|
bool ready_, data_ready_;
|
||||||
// Data of the next row
|
// Data of the next row
|
||||||
string name_, rtype_, rdata_, ttl_;
|
string name_txt_, rtype_txt_, rdata_txt_, ttl_txt_;
|
||||||
|
// RDATA of the next row; created from rdata_txt_.
|
||||||
|
ConstRdataPtr rdata_;
|
||||||
// Whether to modify differing TTL values, or treat a different TTL as
|
// Whether to modify differing TTL values, or treat a different TTL as
|
||||||
// a different RRset
|
// a different RRset
|
||||||
bool separate_rrs_;
|
bool separate_rrs_;
|
||||||
|
Reference in New Issue
Block a user