Commit 451973cb authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner
Browse files

[2207] Use state variable

Instead of several boolean variables.
parent 83f878b6
...@@ -33,8 +33,7 @@ ZoneWriterLocal::ZoneWriterLocal(ZoneTableSegmentLocal* segment, ...@@ -33,8 +33,7 @@ ZoneWriterLocal::ZoneWriterLocal(ZoneTableSegmentLocal* segment,
origin_(origin), origin_(origin),
rrclass_(rrclass), rrclass_(rrclass),
zone_data_(NULL), zone_data_(NULL),
loaded_(false), state_(ZW_UNUSED)
data_ready_(false)
{} {}
ZoneWriterLocal::~ZoneWriterLocal() { ZoneWriterLocal::~ZoneWriterLocal() {
...@@ -45,7 +44,7 @@ ZoneWriterLocal::~ZoneWriterLocal() { ...@@ -45,7 +44,7 @@ ZoneWriterLocal::~ZoneWriterLocal() {
void void
ZoneWriterLocal::load() { ZoneWriterLocal::load() {
if (loaded_) { if (state_ != ZW_UNUSED) {
isc_throw(isc::InvalidOperation, "Trying to load twice"); isc_throw(isc::InvalidOperation, "Trying to load twice");
} }
...@@ -56,13 +55,12 @@ ZoneWriterLocal::load() { ...@@ -56,13 +55,12 @@ ZoneWriterLocal::load() {
isc_throw(isc::InvalidOperation, "No data returned from load action"); isc_throw(isc::InvalidOperation, "No data returned from load action");
} }
loaded_ = true; state_ = ZW_LOADED;
data_ready_ = true;
} }
void void
ZoneWriterLocal::install() { ZoneWriterLocal::install() {
if (!data_ready_) { if (state_ != ZW_LOADED) {
isc_throw(isc::InvalidOperation, "No data to install"); isc_throw(isc::InvalidOperation, "No data to install");
} }
...@@ -75,7 +73,7 @@ ZoneWriterLocal::install() { ...@@ -75,7 +73,7 @@ ZoneWriterLocal::install() {
segment_->getMemorySegment(), segment_->getMemorySegment(),
rrclass_, origin_, zone_data_)); rrclass_, origin_, zone_data_));
data_ready_ = false; state_ = ZW_INSTALLED;
zone_data_ = result.zone_data; zone_data_ = result.zone_data;
} }
...@@ -86,7 +84,7 @@ ZoneWriterLocal::cleanup() { ...@@ -86,7 +84,7 @@ ZoneWriterLocal::cleanup() {
if (zone_data_ != NULL) { if (zone_data_ != NULL) {
ZoneData::destroy(segment_->getMemorySegment(), zone_data_, rrclass_); ZoneData::destroy(segment_->getMemorySegment(), zone_data_, rrclass_);
zone_data_ = NULL; zone_data_ = NULL;
data_ready_ = false; state_ = ZW_CLEANED;
} }
} }
......
...@@ -79,10 +79,13 @@ private: ...@@ -79,10 +79,13 @@ private:
dns::Name origin_; dns::Name origin_;
dns::RRClass rrclass_; dns::RRClass rrclass_;
ZoneData* zone_data_; ZoneData* zone_data_;
// The load was performed enum State {
bool loaded_; ZW_UNUSED,
// The data are ready to be installed ZW_LOADED,
bool data_ready_; ZW_INSTALLED,
ZW_CLEANED
};
State state_;
}; };
} }
......
Supports Markdown
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