mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-30 21:45:37 +00:00
[2205] make AUTH_DATASRC_CLIENTS_BUILDER_COMMAND more readable using text.
also explicitly reject invalid command ID, which should be internal bug.
This commit is contained in:
@@ -275,7 +275,7 @@ A separate thread for maintaining data source clients has been started.
|
|||||||
% AUTH_DATASRC_CLIENTS_BUILDER_STOPPED data source builder thread stopped
|
% AUTH_DATASRC_CLIENTS_BUILDER_STOPPED data source builder thread stopped
|
||||||
The separate thread for maintaining data source clients has been stopped.
|
The separate thread for maintaining data source clients has been stopped.
|
||||||
|
|
||||||
% AUTH_DATASRC_CLIENTS_BUILDER_COMMAND data source builder received command, ID: %1
|
% AUTH_DATASRC_CLIENTS_BUILDER_COMMAND data source builder received command: %1
|
||||||
A debug message, showing when the separate thread for maintaining data
|
A debug message, showing when the separate thread for maintaining data
|
||||||
source clients receives a command from the manager.
|
source clients receives a command from the manager.
|
||||||
|
|
||||||
|
@@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#include <auth/auth_log.h>
|
#include <auth/auth_log.h>
|
||||||
|
|
||||||
|
#include <boost/array.hpp>
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
@@ -42,7 +43,8 @@ namespace datasrc_clientmgr_internal {
|
|||||||
/// \brief ID of commands from the DataSrcClientsMgr to DataSrcClientsBuilder.
|
/// \brief ID of commands from the DataSrcClientsMgr to DataSrcClientsBuilder.
|
||||||
enum CommandID {
|
enum CommandID {
|
||||||
NOOP, ///< Do nothing. Only useful for tests; no argument
|
NOOP, ///< Do nothing. Only useful for tests; no argument
|
||||||
SHUTDOWN ///< Shutdown the builder; no argument
|
SHUTDOWN, ///< Shutdown the builder; no argument
|
||||||
|
NUM_COMMANDS
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \brief The data type passed from DataSrcClientsMgr to
|
/// \brief The data type passed from DataSrcClientsMgr to
|
||||||
@@ -262,14 +264,25 @@ bool
|
|||||||
DataSrcClientsBuilderBase<MutexType, CondVarType>::handleCommand(
|
DataSrcClientsBuilderBase<MutexType, CondVarType>::handleCommand(
|
||||||
const Command& command)
|
const Command& command)
|
||||||
{
|
{
|
||||||
LOG_DEBUG(auth_logger, DBGLVL_TRACE_BASIC,
|
const CommandID cid = command.first;
|
||||||
AUTH_DATASRC_CLIENTS_BUILDER_COMMAND).arg(command.first);
|
if (cid >= NUM_COMMANDS) {
|
||||||
|
// This shouldn't happen except for a bug within this file.
|
||||||
|
isc_throw(Unexpected, "internal bug: invalid command, ID: " << cid);
|
||||||
|
}
|
||||||
|
|
||||||
|
const boost::array<const char*, NUM_COMMANDS> command_desc = {
|
||||||
|
{"NOOP", "SHUTDOWN"}
|
||||||
|
};
|
||||||
|
LOG_DEBUG(auth_logger, DBGLVL_TRACE_BASIC,
|
||||||
|
AUTH_DATASRC_CLIENTS_BUILDER_COMMAND).arg(command_desc.at(cid));
|
||||||
switch (command.first) {
|
switch (command.first) {
|
||||||
case SHUTDOWN:
|
case SHUTDOWN:
|
||||||
return (false);
|
return (false);
|
||||||
case NOOP:
|
case NOOP:
|
||||||
doNoop();
|
doNoop();
|
||||||
|
break;
|
||||||
|
case NUM_COMMANDS:
|
||||||
|
assert(false); // we rejected this case above
|
||||||
}
|
}
|
||||||
return (true);
|
return (true);
|
||||||
}
|
}
|
||||||
|
@@ -96,4 +96,11 @@ TEST_F(DataSrcClientsBuilderTest, shutdown) {
|
|||||||
EXPECT_FALSE(builder.handleCommand(shutdown_cmd));
|
EXPECT_FALSE(builder.handleCommand(shutdown_cmd));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(DataSrcClientsBuilderTest, badCommand) {
|
||||||
|
// out-of-range command ID
|
||||||
|
EXPECT_THROW(builder.handleCommand(Command(NUM_COMMANDS,
|
||||||
|
ConstElementPtr())),
|
||||||
|
isc::Unexpected);
|
||||||
|
}
|
||||||
|
|
||||||
} // unnamed namespace
|
} // unnamed namespace
|
||||||
|
Reference in New Issue
Block a user