Commit 15471a94 authored by Stephen Morris's avatar Stephen Morris
Browse files

[master] Merge branch 'trac3048'

Conflicts:
	src/lib/hooks/server_hooks.cc
parents 56393640 ca923357
......@@ -14,47 +14,57 @@
$NAMESPACE isc::hooks
% HOOKS_ALL_CALLOUTS_DEREGISTERED hook library at index %1 removed all callouts on hook %2
A debug message issued when all callouts on the specified hook registered
by the library with the given index were removed. This is similar to
the HOOKS_CALLOUTS_REMOVED message (and the two are likely to be seen
together), but is issued at a lower-level in the hook framework.
% HOOKS_CALLOUTS_REMOVED callouts removed from hook %1 for library %2
This is a debug message issued during library unloading. It notes that
one of more callouts registered by that library have been removed from
the specified hook. This is similar to the HOOKS_DEREGISTER_ALL_CALLOUTS
message (and the two are likely to be seen together), but is issued at a
higher-level in the hook framework.
% HOOKS_CALLOUT_CALLED hooks library with index %1 has called a callout on hook %2 that has address %3
Only output at a high debugging level, this message indicates that
a callout on the named hook registered by the library with the given
index (in the list of loaded libraries) has been called and returned a
success state. The address of the callout is given in the message
% HOOKS_CALLOUT_DEREGISTERED hook library at index %1 deregistered a callout on hook %2
A debug message issued when all instances of a particular callouts on
the hook identified in the message that were registered by the library
with the given index have been removed.
% HOOKS_CALLOUT_ERROR error returned by callout on hook %1 registered by library with index %2 (callout address %3)
If a callout returns an error status when called, this error message
is issued. It identifies the hook to which the callout is attached, the
index of the library (in the list of loaded libraries) that registered
it and the address of the callout. The error is otherwise ignored.
% HOOKS_CALLOUTS_REMOVED callouts removed from hook %1 for library %2
This is a debug message issued during library unloading. It notes that
one of more callouts registered by that library have been removed from
the specified hook. This is similar to the HOOKS_DEREGISTER_ALL_CALLOUTS
message (and the two are likely to be seen together), but is issued at a
higher-level in the hook framework.
% HOOKS_CLOSE_ERROR failed to close hook library %1: %2
BIND 10 has failed to close the named hook library for the stated reason.
Although this is an error, this should not affect the running system
other than as a loss of resources. If this error persists, you should
restart BIND 10.
% HOOKS_CALLOUT_EXCEPTION exception thrown by callout on hook %1 registered by library with index %2 (callout address %3)
If a callout throws an exception when called, this error message is
issued. It identifies the hook to which the callout is attached, the
index of the library (in the list of loaded libraries) that registered
it and the address of the callout. The error is otherwise ignored.
% HOOKS_ALL_CALLOUTS_DEREGISTERED hook library at index %1 removed all callouts on hook %2
A debug message issued when all callouts on the specified hook registered
by the library with the given index were removed. This is similar to
the HOOKS_CALLOUTS_REMOVED message (and the two are likely to be seen
together), but is issued at a lower-level in the hook framework.
% HOOKS_CALLOUT_REGISTRATION hooks library with index %1 registering callout for hook '%2'
This is a debug message, output when a library (whose index in the list
of libraries (being) loaded is given) registers a callout.
% HOOKS_CALLOUT_DEREGISTERED hook library at index %1 deregistered a callout on hook %2
A debug message issued when all instances of a particular callouts on
the hook identified in the message that were registered by the library
with the given index have been removed.
% HOOKS_CLOSE_ERROR failed to close hook library %1: %2
BIND 10 has failed to close the named hook library for the stated reason.
Although this is an error, this should not affect the running system
other than as a loss of resources. If this error persists, you should
restart BIND 10.
% HOOKS_HOOK_LIST_RESET the list of hooks has been reset
This is a message indicating that the list of hooks has been reset.
While this is usual when running the BIND 10 test suite, it should not be
seen when running BIND 10 in a producion environment. If this appears,
please report a bug through the usual channels.
% HOOKS_INCORRECT_VERSION hook library %1 is at version %2, require version %3
BIND 10 has detected that the named hook library has been built against
......@@ -69,18 +79,24 @@ library should fix the problem in most cases.
This information message is issued when a user-supplied hooks library
has been successfully loaded.
% HOOKS_LIBRARY_LOADING loading hooks library %1
This is a debug message output just before the specified library is loaded.
If the action is successfully, it will be followed by the
HOOKS_LIBRARY_LOADED informational message.
% HOOKS_LIBRARY_UNLOADED hooks library %1 successfully unloaded
This information message is issued when a user-supplied hooks library
has been successfully unloaded.
% HOOKS_LIBRARY_UNLOADING unloading library %1
This is a debug message called when the specified library is
being unloaded. If all is successful, it will be followed by the
HOOKS_LIBRARY_UNLOADED informational message.
% HOOKS_LIBRARY_VERSION hooks library %1 reports its version as %2
A debug message issued when the version check on the hooks library
has succeeded.
% HOOKS_LOAD_SUCCESS 'load' function in hook library %1 returned success
This is a debug message issued when the "load" function has been found
in a hook library and has been successfully called.
% HOOKS_LOAD_ERROR 'load' function in hook library %1 returned error %2
A "load" function was found in the library named in the message and
was called. The function returned a non-zero status (also given in
......@@ -93,10 +109,9 @@ was called. The function threw an exception (an error indication)
during execution, which is an error condition. The library has been
unloaded and no callouts from it will be installed.
% HOOKS_LIBRARY_LOADING loading hooks library %1
This is a debug message output just before the specified library is loaded.
If the action is successfully, it will be followed by the
HOOKS_LIBRARY_LOADED informational message.
% HOOKS_LOAD_SUCCESS 'load' function in hook library %1 returned success
This is a debug message issued when the "load" function has been found
in a hook library and has been successfully called.
% HOOKS_NO_LOAD no 'load' function found in hook library %1
This is a debug message saying that the specified library was loaded
......@@ -120,30 +135,11 @@ BIND 10 failed to open the specified hook library for the stated
reason. The library has not been loaded. BIND 10 will continue to
function, but without the services offered by the library.
% HOOKS_CALLOUT_REGISTRATION hooks library with index %1 registering callout for hook '%2'
This is a debug message, output when a library (whose index in the list
of libraries (being) loaded is given) registers a callout.
% HOOKS_HOOK_REGISTERED hook %1 was registered
This is a debug message indicating that a hook of the specified name
was registered by a BIND 10 server. The server doing the logging is
indicated by the full name of the logger used to log this message.
% HOOKS_STD_CALLOUT_REGISTERED hooks library %1 registered standard callout for hook %2 at address %3
This is a debug message, output when the library loading function has
located a standard callout (a callout with the same name as a hook point)
and registered it. The address of the callout is indicated.
% HOOKS_HOOK_LIST_RESET the list of hooks has been reset
This is a message indicating that the list of hooks has been reset.
While this is usual when running the BIND 10 test suite, it should not be
seen when running BIND 10 in a producion environment. If this appears,
please report a bug through the usual channels.
% HOOKS_UNLOAD_SUCCESS 'unload' function in hook library %1 returned success
This is a debug message issued when an "unload" function has been found
in a hook library during the unload process, called, and returned success.
% HOOKS_UNLOAD_ERROR 'unload' function in hook library %1 returned error %2
During the unloading of a library, an "unload" function was found.
It was called, but returned an error (non-zero) status, resulting in
......@@ -156,10 +152,9 @@ called, but in the process generated an exception (an error indication).
The unload process continued after this message and the library has
been unloaded.
% HOOKS_LIBRARY_UNLOADING unloading library %1
This is a debug message called when the specified library is
being unloaded. If all is successful, it will be followed by the
HOOKS_LIBRARY_UNLOADED informational message.
% HOOKS_UNLOAD_SUCCESS 'unload' function in hook library %1 returned success
This is a debug message issued when an "unload" function has been found
in a hook library during the unload process, called, and returned success.
% HOOKS_VERSION_EXCEPTION 'version' function in hook library %1 threw an exception
This error message is issued if the version() function in the specified
......
......@@ -27,9 +27,18 @@ namespace hooks {
// Constructor - register the pre-defined hooks and check that the indexes
// assigned to them are as expected.
//
// Note that there are no logging messages here or in registerHooks(). The
// recommended way to initialize hook names is to use static initialization.
// Here, a static object is declared in a file outside of any function or
// method. As a result, it is instantiated and its constructor run before the
// program starts. By putting calls to ServerHooks::registerHook() in there,
// hooks names are already registered when the program runs. However, at that
// point, the logging system is not initialized, so messages are unable to
// be output.
ServerHooks::ServerHooks() {
reset();
initialize();
}
// Register a hook. The index assigned to the hook is the current number
......@@ -54,18 +63,14 @@ ServerHooks::registerHook(const string& name) {
// Element was inserted, so add to the inverse hooks collection.
inverse_hooks_[index] = name;
// Log it if debug is enabled
/// @todo See todo comment in reset() below.
//LOG_DEBUG(hooks_logger, HOOKS_DBG_TRACE, HOOKS_HOOK_REGISTERED).arg(name);
// ... and return numeric index.
return (index);
}
// Reset ServerHooks object to initial state.
// Set ServerHooks object to initial state.
void
ServerHooks::reset() {
ServerHooks::initialize() {
// Clear out the name->index and index->name maps.
hooks_.clear();
......@@ -83,15 +88,19 @@ ServerHooks::reset() {
". context_destroy: expected = " << CONTEXT_DESTROY <<
", actual = " << destroy);
}
}
// Reset ServerHooks object to initial state.
void
ServerHooks::reset() {
// Clear all hooks then initialize the pre-defined ones.
initialize();
// Log a warning - although this is done during testing, it should never be
// seen in a production system.
/// @todo Implement proper workaround here. The issue is when the first
/// module (e.g. Dhcp6Srv module) initializes global structure it calls
/// HooksManager::registerHooks() which in turn creates ServerHooks object.
/// Its constructor calls reset() method, but the loggers are not initialized
/// yet and exception is thrown.
//LOG_WARN(hooks_logger, HOOKS_HOOK_LIST_RESET);
LOG_WARN(hooks_logger, HOOKS_HOOK_LIST_RESET);
}
// Find the name associated with a hook index.
......
......@@ -74,8 +74,8 @@ public:
///
/// Resets the collection of hooks to the initial state, with just the
/// context_create and context_destroy hooks set. This used during
/// construction. It is also used during testing to reset the global
/// ServerHooks object.
/// testing to reset the global ServerHooks object; it should never be
/// used in production.
///
/// @throws isc::Unexpected if the registration of the pre-defined hooks
/// fails in some way.
......@@ -149,7 +149,7 @@ private:
/// for the packet has completed. They allow the server code to allocate
/// and destroy per-packet context.
///
/// Constructor is declared private to enforce the singleton nature of
/// The constructor is declared private to enforce the singleton nature of
/// the object. A reference to the singleton is obtainable through the
/// getServerHooks() static method.
///
......@@ -157,6 +157,16 @@ private:
/// fails in some way.
ServerHooks();
/// @brief Initialize hooks
///
/// Sets the collection of hooks to the initial state, with just the
/// context_create and context_destroy hooks set. This is used during
/// construction.
///
/// @throws isc::Unexpected if the registration of the pre-defined hooks
/// fails in some way.
void initialize();
/// Useful typedefs.
typedef std::map<std::string, int> HookCollection;
typedef std::map<int, std::string> InverseHookCollection;
......
Markdown is supported
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