33 LibraryManager::LibraryManager(
const std::string& name,
int index,
34 const boost::shared_ptr<CalloutManager>& manager)
35 : dl_handle_(NULL), index_(index), manager_(manager),
41 "instantiating a LibraryManager object");
53 : dl_handle_(NULL), index_(-1), manager_(), library_name_(name)
76 dl_handle_ = dlopen(library_name_.c_str(), RTLD_NOW | RTLD_LOCAL);
77 if (dl_handle_ == NULL) {
82 return (dl_handle_ != NULL);
92 if (dl_handle_ != NULL) {
93 status = dlclose(dl_handle_);
103 return (status == 0);
114 int version = KEA_HOOKS_VERSION - 1;
122 if (version == KEA_HOOKS_VERSION) {
125 .arg(library_name_).arg(version);
130 .arg(version).arg(KEA_HOOKS_VERSION);
150 PointerConverter pc(dlsym(dl_handle_, MULTI_THREADING_COMPATIBLE_FUNCTION_NAME));
166 if (compatible == 0) {
170 return (compatible != 0);
179 manager_->setLibraryIndex(index_);
183 for (
size_t i = 0; i < hook_names.size(); ++i) {
186 void* dlsym_ptr = dlsym(dl_handle_, hook_names[i].c_str());
190 manager_->getLibraryHandle().registerCallout(hook_names[i],
194 .arg(hook_names[i]).arg(dlsym_ptr);
215 manager_->setLibraryIndex(index_);
216 status = (*pc.
loadPtr())(manager_->getLibraryHandle());
219 .arg(library_name_).arg(ex.
what());
250 if (dl_handle_ == NULL) {
273 .arg(library_name_).arg(ex.
what());
299 manager_->setLibraryIndex(index_);
300 for (
size_t i = 0; i < hooks.size(); ++i) {
301 bool removed = manager_->deregisterAllCallouts(hooks[i], index_);
304 .arg(hooks[i]).arg(library_name_);
381 if (dl_handle_ != NULL) {
const isc::log::MessageID HOOKS_LOAD_ERROR
#define LOG_WARN(LOGGER, MESSAGE)
Macro to conveniently test warn output and log it.
static void logDuplicatedMessages()
List duplicated log messages.
bool unloadLibrary()
Unloads a library.
void hooksStaticLinkInit()
User-Library Initialization for Statically-Linked Kea.
#define LOG_INFO(LOGGER, MESSAGE)
Macro to conveniently test info output and log it.
static MultiThreadingMgr & instance()
Returns a single instance of Multi Threading Manager.
const isc::log::MessageID HOOKS_LIBRARY_LOADING
bool checkMultiThreadingCompatible() const
Check multi-threading compatibility.
const isc::log::MessageID HOOKS_LIBRARY_MULTI_THREADING_NOT_COMPATIBLE
static ServerHooks & getServerHooks()
Return ServerHooks object.
multi_threading_compatible_function_ptr multiThreadingCompatiblePtr() const
Return pointer to multi_threading_compatible function.
const isc::log::MessageID HOOKS_LIBRARY_LOADED
bool loadLibrary()
Loads a library.
const isc::log::MessageID HOOKS_LOAD_FRAMEWORK_EXCEPTION
CalloutPtr calloutPtr() const
Return pointer to callout function.
const isc::log::MessageID HOOKS_UNLOAD_FRAMEWORK_EXCEPTION
const isc::log::MessageID HOOKS_LIBRARY_MULTI_THREADING_COMPATIBLE
#define LOG_ERROR(LOGGER, MESSAGE)
Macro to conveniently test error output and log it.
bool checkVersion() const
Check library version.
const isc::log::MessageID HOOKS_LIBRARY_UNLOADED
load_function_ptr loadPtr() const
Return pointer to load function.
static bool validateLibrary(const std::string &name)
Validate library.
const isc::log::MessageID HOOKS_LIBRARY_CLOSED
Local class for conversion of void pointers to function pointers.
static void loadDictionary(bool ignore_duplicates=false)
Run-Time Initialization.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
const isc::log::MessageID HOOKS_UNLOAD_EXCEPTION
const isc::log::MessageID HOOKS_LIBRARY_VERSION
bool isLoggingInitialized()
Is logging initialized?
int version()
returns Kea hooks version.
const isc::log::MessageID HOOKS_VERSION_EXCEPTION
const isc::log::MessageID HOOKS_LOAD_SUCCESS
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
const isc::log::MessageID HOOKS_OPEN_ERROR
version_function_ptr versionPtr() const
Return pointer to version function.
void registerStandardCallouts()
Register standard callouts.
const isc::log::MessageID HOOKS_NO_VERSION
const int HOOKS_DBG_CALLS
const isc::log::MessageID HOOKS_LOAD_EXCEPTION
const isc::log::MessageID HOOKS_CALLOUTS_REMOVED
This is a base class for exceptions thrown from the DNS library module.
Defines the logger used by the top-level component of kea-dhcp-ddns.
const isc::log::MessageID HOOKS_NO_LOAD
~LibraryManager()
Destructor.
const isc::log::MessageID HOOKS_UNLOAD_SUCCESS
Logging initialization functions.
isc::log::Logger hooks_logger("hooks")
Hooks Logger.
bool prepareUnloadLibrary()
Prepares library unloading.
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
unload_function_ptr unloadPtr() const
Return pointer to unload function.
bool runLoad()
Run the load function if present.
bool openLibrary()
Open library.
void initLogger(const string &root, isc::log::Severity severity, int dbglevel, const char *file, bool buffer)
Run-time initialization.
const isc::log::MessageID HOOKS_INCORRECT_VERSION
bool closeLibrary()
Close library.
const isc::log::MessageID HOOKS_UNLOAD_ERROR
const isc::log::MessageID HOOKS_NO_UNLOAD
LibraryManager(const std::string &name, int index, const boost::shared_ptr< CalloutManager > &manager)
Constructor.
const isc::log::MessageID HOOKS_MULTI_THREADING_COMPATIBLE_EXCEPTION
const int HOOKS_DBG_TRACE
Hooks debug Logging levels.
const isc::log::MessageID HOOKS_STD_CALLOUT_REGISTERED
std::vector< std::string > getHookNames() const
Get hook names.
const isc::log::MessageID HOOKS_LIBRARY_UNLOADING
const isc::log::MessageID HOOKS_CLOSE_ERROR