#include <config.h>
#include <exceptions/exceptions.h>
-#if 0
-#include <util/multi_threading_mgr.h>
-#endif
#include <hooks/hooks.h>
#include <hooks/hooks_log.h>
#include <hooks/callout_manager.h>
#include <log/logger_manager.h>
#include <log/logger_support.h>
#include <log/message_initializer.h>
+#include <util/multi_threading_mgr.h>
#include <string>
#include <vector>
namespace isc {
namespace hooks {
-
// Constructor (used by external agency)
LibraryManager::LibraryManager(const std::string& name, int index,
const boost::shared_ptr<CalloutManager>& manager)
LibraryManager::checkMultiThreadingCompatible() const {
// Compatible with single-threaded.
-#if 0
- if (!MultiThreadingMgr::instance().getMode()) {
+ if (!util::MultiThreadingMgr::instance().getMode()) {
return (true);
}
-#endif
// Get the pointer to the "multi_threading_compatible" function.
PointerConverter pc(dlsym(dl_handle_, MULTI_THREADING_COMPATIBLE_FUNCTION_NAME));
// Library opened OK, see if a version function is present and if so,
// check what value it returns. Check multi-threading compatibility.
-#if 0
if (checkVersion() && checkMultiThreadingCompatible()) {
-#else
- if (checkVersion()) {
-#endif
// Version OK, so now register the standard callouts and call the
// library's load() function if present.
registerStandardCallouts();
LibraryManager manager(name);
// Try to open it and, if we succeed, check the version.
-#if 0
bool validated = manager.openLibrary() && manager.checkVersion() &&
- checkMultiThreadingCompatible();
-#else
- bool validated = manager.openLibrary() && manager.checkVersion();
-#endif
+ manager.checkMultiThreadingCompatible();
// Regardless of whether the version checked out, close the library. (This
// is a no-op if the library failed to open.)
#include <log/message_dictionary.h>
#include <log/message_initializer.h>
-#if 0
#include <util/multi_threading_mgr.h>
-#endif
#include <gtest/gtest.h>
using namespace isc;
using namespace isc::hooks;
using namespace isc::log;
+using namespace isc::util;
using namespace std;
namespace {
// Ensure the marker file is not present at the start of a test.
static_cast<void>(remove(MARKER_FILE));
+
+ // Disable multi-threading.
}
/// @brief Destructor
/// Ensures a marker file is removed after each test.
~LibraryManagerTest() {
static_cast<void>(remove(MARKER_FILE));
+ MultiThreadingMgr::instance().setMode(false);
}
/// @brief Marker file present
// Open should succeed.
EXPECT_TRUE(lib_manager.openLibrary());
-#if 0
// Not multi-threading compatible: does not matter without MT.
EXPECT_TRUE(lib_manager.checkMultiThreadingCompatible());
// Not multi-threading compatible: does matter with MT.
- //// set MT
+ MultiThreadingMgr::instance().setMode(true);
EXPECT_FALSE(lib_manager.checkMultiThreadingCompatible());
-#endif
// Tidy up.
EXPECT_TRUE(lib_manager.closeLibrary());
// Open should succeed.
EXPECT_TRUE(lib_manager.openLibrary());
-#if 0
// Not multi-threading compatible: does not matter without MT.
EXPECT_TRUE(lib_manager.checkMultiThreadingCompatible());
// Not multi-threading compatible: does matter with MT.
- //// set MT
+ MultiThreadingMgr::instance().setMode(true);
EXPECT_FALSE(lib_manager.checkMultiThreadingCompatible());
-#endif
// Tidy up.
EXPECT_TRUE(lib_manager.closeLibrary());
EXPECT_TRUE(lib_manager.checkMultiThreadingCompatible());
// Multi-threading compatible: does matter with MT.
- //// set MT
+ MultiThreadingMgr::instance().setMode(true);
EXPECT_TRUE(lib_manager.checkMultiThreadingCompatible());
// Tidy up.
// Open should succeed.
EXPECT_TRUE(lib_manager.openLibrary());
-#if 0
// Throw exception: does not matter without MT.
- EXPECT_FALSE(lib_manager.checkMultiThreadingCompatible());
-#endif
+ EXPECT_TRUE(lib_manager.checkMultiThreadingCompatible());
// Throw exception: does matter with MT.
- //// set MT
+ MultiThreadingMgr::instance().setMode(true);
EXPECT_FALSE(lib_manager.checkMultiThreadingCompatible());
// Tidy up.
EXPECT_FALSE(LibraryManager::validateLibrary(NO_VERSION_LIBRARY));
EXPECT_TRUE(LibraryManager::validateLibrary(UNLOAD_CALLOUT_LIBRARY));
EXPECT_TRUE(LibraryManager::validateLibrary(CALLOUT_PARAMS_LIBRARY));
+
+ MultiThreadingMgr::instance().setMode(true);
+
+ EXPECT_FALSE(LibraryManager::validateLibrary(BASIC_CALLOUT_LIBRARY));
+ EXPECT_TRUE(LibraryManager::validateLibrary(FULL_CALLOUT_LIBRARY));
+ EXPECT_FALSE(LibraryManager::validateLibrary(FRAMEWORK_EXCEPTION_LIBRARY));
+ EXPECT_FALSE(LibraryManager::validateLibrary(INCORRECT_VERSION_LIBRARY));
+ EXPECT_FALSE(LibraryManager::validateLibrary(LOAD_CALLOUT_LIBRARY));
+ EXPECT_FALSE(LibraryManager::validateLibrary(LOAD_ERROR_CALLOUT_LIBRARY));
+ EXPECT_FALSE(LibraryManager::validateLibrary(NOT_PRESENT_LIBRARY));
+ EXPECT_FALSE(LibraryManager::validateLibrary(NO_VERSION_LIBRARY));
+ EXPECT_FALSE(LibraryManager::validateLibrary(UNLOAD_CALLOUT_LIBRARY));
+ EXPECT_FALSE(LibraryManager::validateLibrary(CALLOUT_PARAMS_LIBRARY));
}
// Check that log messages are properly registered and unregistered.