Commit 017278ca authored by Stephen Morris's avatar Stephen Morris
Browse files

[2980] Added LibraryManager::runUnload()

parent e61a5182
......@@ -29,11 +29,11 @@ This is most likely due to the installation of a new version of BIND 10
without rebuilding the hook library. A rebuild and re-install of the library
should fix the problem in most cases.
% HOOKS_LOAD 'load' function in hook library %1 found and successfully called
% HOOKS_LOAD '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 hook library %1 has 'load' function returing error code %2
% 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 the message)
which was interpreted as an error. The library has been unloaded and
......@@ -45,6 +45,10 @@ no function called "load" was found in it. Providing the library contained
some "standard" functions (i.e. functions with the names of the hooks for
the given server), this is not an issue.
% HOOKS_NO_UNLOAD no 'unload' function found in hook library %1
This is a debug message issued when the library is being unloaded. It merely
states that the library did not contain an "unload" function.
% HOOKS_NO_VERSION no 'version' function found in hook library %1
The shared library named in the message was found and successfully loaded, but
BIND 10 did not find a function named "version" in it. This function is
......@@ -61,3 +65,13 @@ the services offered by the library.
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.
% HOOKS_UNLOAD '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 the issuing of
this message. The unload process continued after this message and the library
has been unloaded.
......@@ -29,7 +29,7 @@ namespace {
// String constants
const char* LOAD_FUNCTION_NAME = "load";
// const char* UNLOAD = "unload";
const char* UNLOAD_FUNCTION_NAME = "unload";
const char* VERSION_FUNCTION_NAME = "version";
}
......@@ -193,5 +193,45 @@ LibraryManager::runLoad() {
}
// Run the "unload" function if present.
bool
LibraryManager::runUnload() {
// Look up the "load" function in the library. The code here is similar
// to that in "checkVersion".
union {
unload_function_ptr unload_ptr;
void* dlsym_ptr;
} pointers;
// Zero the union, whatever the size of the pointers.
pointers.unload_ptr = NULL;
pointers.dlsym_ptr = NULL;
// Get the pointer to the "load" function.
pointers.dlsym_ptr = dlsym(dl_handle_, UNLOAD_FUNCTION_NAME);
if (pointers.unload_ptr != NULL) {
// Call the load() function with the library handle. We need to set
// the CalloutManager's index appropriately. We'll invalidate it
// afterwards.
int status = (*pointers.unload_ptr)();
if (status != 0) {
LOG_ERROR(hooks_logger, HOOKS_UNLOAD_ERROR).arg(library_name_)
.arg(status);
return (false);
} else {
LOG_DEBUG(hooks_logger, HOOKS_DBG_TRACE, HOOKS_UNLOAD)
.arg(library_name_);
}
} else {
LOG_DEBUG(hooks_logger, HOOKS_DBG_TRACE, HOOKS_NO_UNLOAD)
.arg(library_name_);
}
return (true);
}
} // namespace hooks
} // namespace isc
......@@ -171,7 +171,7 @@ protected:
/// @return bool true if not found or found and run successfully,
/// false on an error. In this case, an error message will
/// have been output.
bool runUnload() {return false;}
bool runUnload();
private:
void* dl_handle_; ///< Handle returned by dlopen
......
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