-// Copyright (C) 2017-2019 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2017-2020 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
#include <agent/simple_parser.h>
#include <cc/data.h>
#include <cc/dhcp_config_error.h>
+#include <hooks/hooks_manager.h>
#include <hooks/hooks_parser.h>
#include <boost/foreach.hpp>
// This occurs last as if it succeeds, there is no easy way
// revert it. As a result, the failure to commit a subsequent
// change causes problems when trying to roll back.
+ HooksManager::prepareUnloadLibraries();
+ static_cast<void>(HooksManager::unloadLibraries());
libraries.loadLibraries();
}
}
-};
-};
+}
+}
-// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2018-2020 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
#include <netconf/netconf_config.h>
#include <cc/data.h>
#include <cc/dhcp_config_error.h>
+#include <hooks/hooks_manager.h>
#include <hooks/hooks_parser.h>
#include <boost/foreach.hpp>
// This occurs last as if it succeeds, there is no easy way
// revert it. As a result, the failure to commit a subsequent
// change causes problems when trying to roll back.
+ HooksManager::prepareUnloadLibraries();
+ static_cast<void>(HooksManager::unloadLibraries());
libraries.loadLibraries();
}
}
-};
-};
+}
+}
wthread_->markReady(WatchedThread::READY);
- // In fact below only the terminate matters as in fact
- // accepts have not the time to be called.
for (;;) {
int nfd;
fd_set fds;
FD_ZERO(&fds);
FD_SET(wthread_->getWatchFd(WatchedThread::TERMINATE), &fds);
nfd = wthread_->getWatchFd(WatchedThread::TERMINATE);
- // FD_SET(accept_partner1, &fds);
+ FD_SET(accept_partner1, &fds);
if (accept_partner1 > nfd) {
nfd = accept_partner1;
}
- // FD_SET(accept_partner2, &fds);
+ FD_SET(accept_partner2, &fds);
if (accept_partner2 > nfd) {
nfd = accept_partner2;
}
// Use the query callout handle.
CalloutHandlePtr handle = query->getCalloutHandle();
ScopedCalloutHandleState handle_state(handle);
- handle->setStatus(CalloutHandle::NEXT_STEP_SKIP);
handle->setArgument("query6", query);
HooksManager::callCallouts(testHooks.hook_index_buffer6_receive_,
*handle);
// Constructor
HooksManager::HooksManager() : test_mode_(false) {
- init();
+ // Nothing present, so create the collection with any empty set of
+ // libraries, and get the CalloutManager.
+ HookLibsCollection libraries;
+ lm_collection_.reset(new LibraryManagerCollection(libraries));
+ lm_collection_->loadLibraries();
+ callout_manager_ = lm_collection_->getCalloutManager();
}
// Return reference to singleton hooks manager.
} else {
// Unable to load libraries, reset to state before this function was
// called.
- init();
+ static_cast<void>(unloadLibrariesInternal());
}
return (status);
return (true);
}
-bool HooksManager::unloadLibraries() {
+bool
+HooksManager::unloadLibraries() {
return (getHooksManager().unloadLibrariesInternal());
}
static_cast<void>(lm_collection_->prepareUnloadLibraries());
}
-void HooksManager::prepareUnloadLibraries() {
+void
+HooksManager::prepareUnloadLibraries() {
getHooksManager().prepareUnloadLibrariesInternal();
}
return (getHooksManager().getLibraryInfoInternal());
}
-// Perform initialization
-
-void
-HooksManager::init() {
- // Nothing present, so create the collection with any empty set of
- // libraries, and get the CalloutManager.
- HookLibsCollection libraries;
- lm_collection_.reset(new LibraryManagerCollection(libraries));
- lm_collection_->loadLibraries();
- callout_manager_ = lm_collection_->getCalloutManager();
-}
-
// Shell around ServerHooks::registerHook()
int
//@}
- /// @brief Initialization to No Libraries
- ///
- /// Initializes the hooks manager with an empty set of libraries.
- void init();
-
// Members
/// Set of library managers.
///
- /// @node: This should always be initialized using @ref init or
- /// @ref loadLibraries.
+ /// @node: This should never be null.
boost::shared_ptr<LibraryManagerCollection> lm_collection_;
/// Callout manager for the set of library managers.
///
- /// @node: This should always be initialized using @ref init or
- /// @ref loadLibraries.
+ /// @node: This should never be null.
boost::shared_ptr<CalloutManager> callout_manager_;
/// Test flag to keep @ref callout_manager_ when calling @ref loadLibraries
-// File created from ../../../src/lib/hooks/hooks_messages.mes on Wed Jun 24 2020 22:17
+// File created from ../../../src/lib/hooks/hooks_messages.mes on Tue Jun 30 2020 14:43
#include <cstddef>
#include <log/message_types.h>
extern const isc::log::MessageID HOOKS_LIBRARY_MULTI_THREADING_NOT_COMPATIBLE = "HOOKS_LIBRARY_MULTI_THREADING_NOT_COMPATIBLE";
extern const isc::log::MessageID HOOKS_LIBRARY_UNLOADED = "HOOKS_LIBRARY_UNLOADED";
extern const isc::log::MessageID HOOKS_LIBRARY_UNLOADING = "HOOKS_LIBRARY_UNLOADING";
-extern const isc::log::MessageID HOOKS_LIBRARY_UNLOAD_ALREADY_CALLED = "HOOKS_LIBRARY_UNLOAD_ALREADY_CALLED";
extern const isc::log::MessageID HOOKS_LIBRARY_VERSION = "HOOKS_LIBRARY_VERSION";
extern const isc::log::MessageID HOOKS_LOAD_ERROR = "HOOKS_LOAD_ERROR";
extern const isc::log::MessageID HOOKS_LOAD_EXCEPTION = "HOOKS_LOAD_EXCEPTION";
"HOOKS_LIBRARY_MULTI_THREADING_NOT_COMPATIBLE", "hooks library %1 is not compatible with multi-threading",
"HOOKS_LIBRARY_UNLOADED", "hooks library %1 successfully unloaded",
"HOOKS_LIBRARY_UNLOADING", "unloading library %1",
- "HOOKS_LIBRARY_UNLOAD_ALREADY_CALLED", "hooks library %1 unload() was already called",
"HOOKS_LIBRARY_VERSION", "hooks library %1 reports its version as %2",
"HOOKS_LOAD_ERROR", "'load' function in hook library %1 returned error %2",
"HOOKS_LOAD_EXCEPTION", "'load' function in hook library %1 threw an exception",
-// File created from ../../../src/lib/hooks/hooks_messages.mes on Wed Jun 24 2020 22:17
+// File created from ../../../src/lib/hooks/hooks_messages.mes on Tue Jun 30 2020 14:43
#ifndef HOOKS_MESSAGES_H
#define HOOKS_MESSAGES_H
extern const isc::log::MessageID HOOKS_LIBRARY_MULTI_THREADING_NOT_COMPATIBLE;
extern const isc::log::MessageID HOOKS_LIBRARY_UNLOADED;
extern const isc::log::MessageID HOOKS_LIBRARY_UNLOADING;
-extern const isc::log::MessageID HOOKS_LIBRARY_UNLOAD_ALREADY_CALLED;
extern const isc::log::MessageID HOOKS_LIBRARY_VERSION;
extern const isc::log::MessageID HOOKS_LOAD_ERROR;
extern const isc::log::MessageID HOOKS_LOAD_EXCEPTION;
This information message is issued when a user-supplied hooks library
has been successfully unloaded.
-% HOOKS_LIBRARY_UNLOAD_ALREADY_CALLED hooks library %1 unload() was already called
-This warning message is issued when the unload() function of a
-user-supplied hooks library was already called.
-
% 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
// Call once.
if (index_ < 0) {
- LOG_WARN(hooks_logger, HOOKS_LIBRARY_UNLOAD_ALREADY_CALLED)
- .arg(library_name_);
- return (false);
+ return (true);
}
// Get the pointer to the "load" function.