Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Adam Osuchowski
Kea
Commits
02e0859b
Commit
02e0859b
authored
Jul 09, 2013
by
Michal 'vorner' Vaner
Browse files
[2862] Auxiliary function to get list of classes
parent
d26eac8d
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/bin/auth/datasrc_clients_mgr.h
View file @
02e0859b
...
...
@@ -212,6 +212,24 @@ public:
return
(
it
->
second
);
}
}
/// \brief Return list of classes that are present.
///
/// Get the list of classes for which there's a client list. It is
/// returned in form of a vector, copied from the internals. As the
/// number of classes in there is expected to be small, it is not
/// a performance issue.
///
/// \return The list of classes.
/// \throw std::bad_alloc for problems allocating the result.
std
::
vector
<
dns
::
RRClass
>
getClasses
()
const
{
std
::
vector
<
dns
::
RRClass
>
result
;
for
(
ClientListsMap
::
const_iterator
it
=
mgr_
.
clients_map_
->
begin
();
it
!=
mgr_
.
clients_map_
->
end
();
++
it
)
{
result
.
push_back
(
it
->
first
);
}
return
(
result
);
}
private:
DataSrcClientsMgrBase
&
mgr_
;
typename
MutexType
::
Locker
locker_
;
...
...
src/bin/auth/tests/datasrc_clients_mgr_unittest.cc
View file @
02e0859b
...
...
@@ -156,6 +156,7 @@ TEST(DataSrcClientsMgrTest, holder) {
TestDataSrcClientsMgr
::
Holder
holder
(
mgr
);
EXPECT_FALSE
(
holder
.
findClientList
(
RRClass
::
IN
()));
EXPECT_FALSE
(
holder
.
findClientList
(
RRClass
::
CH
()));
EXPECT_TRUE
(
holder
.
getClasses
().
empty
());
// map should be protected here
EXPECT_EQ
(
1
,
FakeDataSrcClientsBuilder
::
map_mutex
->
lock_count
);
EXPECT_EQ
(
0
,
FakeDataSrcClientsBuilder
::
map_mutex
->
unlock_count
);
...
...
@@ -174,6 +175,7 @@ TEST(DataSrcClientsMgrTest, holder) {
TestDataSrcClientsMgr
::
Holder
holder
(
mgr
);
EXPECT_TRUE
(
holder
.
findClientList
(
RRClass
::
IN
()));
EXPECT_TRUE
(
holder
.
findClientList
(
RRClass
::
CH
()));
EXPECT_EQ
(
2
,
holder
.
getClasses
().
size
());
}
// We need to clear command queue by hand
FakeDataSrcClientsBuilder
::
command_queue
->
clear
();
...
...
@@ -188,6 +190,7 @@ TEST(DataSrcClientsMgrTest, holder) {
TestDataSrcClientsMgr
::
Holder
holder
(
mgr
);
EXPECT_TRUE
(
holder
.
findClientList
(
RRClass
::
IN
()));
EXPECT_FALSE
(
holder
.
findClientList
(
RRClass
::
CH
()));
EXPECT_EQ
(
RRClass
::
IN
(),
holder
.
getClasses
()[
0
]);
}
// Duplicate lock acquisition is prohibited (only test mgr can detect
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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