-// Copyright (C) 2015-2019 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2015-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
// Delete previously set arguments
callout_handle->deleteAllArguments();
+ // Use the RAII wrapper to make sure that the callout handle state is
+ // reset when this object goes out of scope. All hook points must do
+ // it to prevent possible circular dependency between the callout
+ // handle and its arguments.
+ ScopedCalloutHandleState callout_handle_state(callout_handle);
+
// Enable copying options from the packet within hook library.
ScopedEnableOptionsCopy<Pkt4> response4_options_copy(rsp);
/// @brief destructor (deletes Dhcpv4Srv)
virtual ~HooksDhcpv4SrvTest() {
-
// clear static buffers
resetCalloutBuffers();
// This occurs last as if it succeeds, there is no easy way to
// revert it. As a result, the failure to commit a subsequent
// change causes problems when trying to roll back.
- const HooksConfig& libraries =
- CfgMgr::instance().getStagingCfg()->getHooksConfig();
HooksManager::prepareUnloadLibraries();
static_cast<void>(HooksManager::unloadLibraries());
+ const HooksConfig& libraries =
+ CfgMgr::instance().getStagingCfg()->getHooksConfig();
libraries.loadLibraries();
}
catch (const isc::Exception& ex) {
/// library manager collection) the method will fail to close
/// libraries and returns false. It is a fatal error as there
/// is no possible recovery. It is a logic error in the hook
- /// code too so the solution is to fix the it and to restart
+ /// code too so the solution is to fix it and to restart
/// the server with a correct hook library binary.
///
/// @return true if all libraries unloaded successfully, false if they
/// @brief Prepare the unloading of libraries
///
- /// Calls the unload functions when they exists and removes callouts.
+ /// Calls the unload functions when they exist and removes callouts.
///
/// @note: after the call to this method there should be no visible
/// dangling pointers (i.e. callout handles owning the library
bool
LibraryManagerCollection::loadLibraries() {
- // There must be not libraries still in memory.
+ // There must be no libraries still in memory.
if (!lib_managers_.empty()) {
isc_throw(LibrariesStillOpened, "some libraries are still opened");
}
// Check that the full loadLibrary call works.
TEST_F(LibraryManagerTest, LoadLibrary) {
- PublicLibraryManager lib_manager(std::string(FULL_CALLOUT_LIBRARY), 0,
- callout_manager_);
+ PublicLibraryManager lib_manager(std::string(FULL_CALLOUT_LIBRARY), 0,
+ callout_manager_);
EXPECT_TRUE(lib_manager.loadLibrary());
// Now execute the callouts in the order expected. The library performs