Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sebastian Schrader
Kea
Commits
451973cb
Commit
451973cb
authored
Oct 19, 2012
by
Michal 'vorner' Vaner
Browse files
[2207] Use state variable
Instead of several boolean variables.
parent
83f878b6
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/lib/datasrc/memory/zone_writer_local.cc
View file @
451973cb
...
...
@@ -33,8 +33,7 @@ ZoneWriterLocal::ZoneWriterLocal(ZoneTableSegmentLocal* segment,
origin_
(
origin
),
rrclass_
(
rrclass
),
zone_data_
(
NULL
),
loaded_
(
false
),
data_ready_
(
false
)
state_
(
ZW_UNUSED
)
{}
ZoneWriterLocal
::~
ZoneWriterLocal
()
{
...
...
@@ -45,7 +44,7 @@ ZoneWriterLocal::~ZoneWriterLocal() {
void
ZoneWriterLocal
::
load
()
{
if
(
loaded_
)
{
if
(
state_
!=
ZW_UNUSED
)
{
isc_throw
(
isc
::
InvalidOperation
,
"Trying to load twice"
);
}
...
...
@@ -56,13 +55,12 @@ ZoneWriterLocal::load() {
isc_throw
(
isc
::
InvalidOperation
,
"No data returned from load action"
);
}
loaded_
=
true
;
data_ready_
=
true
;
state_
=
ZW_LOADED
;
}
void
ZoneWriterLocal
::
install
()
{
if
(
!
data_ready_
)
{
if
(
state_
!=
ZW_LOADED
)
{
isc_throw
(
isc
::
InvalidOperation
,
"No data to install"
);
}
...
...
@@ -75,7 +73,7 @@ ZoneWriterLocal::install() {
segment_
->
getMemorySegment
(),
rrclass_
,
origin_
,
zone_data_
));
data_ready_
=
false
;
state_
=
ZW_INSTALLED
;
zone_data_
=
result
.
zone_data
;
}
...
...
@@ -86,7 +84,7 @@ ZoneWriterLocal::cleanup() {
if
(
zone_data_
!=
NULL
)
{
ZoneData
::
destroy
(
segment_
->
getMemorySegment
(),
zone_data_
,
rrclass_
);
zone_data_
=
NULL
;
data_ready_
=
false
;
state_
=
ZW_CLEANED
;
}
}
...
...
src/lib/datasrc/memory/zone_writer_local.h
View file @
451973cb
...
...
@@ -79,10 +79,13 @@ private:
dns
::
Name
origin_
;
dns
::
RRClass
rrclass_
;
ZoneData
*
zone_data_
;
// The load was performed
bool
loaded_
;
// The data are ready to be installed
bool
data_ready_
;
enum
State
{
ZW_UNUSED
,
ZW_LOADED
,
ZW_INSTALLED
,
ZW_CLEANED
};
State
state_
;
};
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment