BIND 10 trac2995, updated. 682cac0da7b318a81746d93424a638faa867ee7c [2995] Hook point registration now matches guide document.
BIND 10 source code commits
bind10-changes at lists.isc.org
Tue Jul 9 17:50:39 UTC 2013
The branch, trac2995 has been updated
via 682cac0da7b318a81746d93424a638faa867ee7c (commit)
from 19c93b0845947d0bb5ff60c602d5fd3f64c531f2 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 682cac0da7b318a81746d93424a638faa867ee7c
Author: Tomek Mrugalski <tomasz at isc.org>
Date: Tue Jul 9 19:23:05 2013 +0200
[2995] Hook point registration now matches guide document.
-----------------------------------------------------------------------
Summary of changes:
src/bin/dhcp4/tests/dhcp4_srv_unittest.cc | 5 ----
src/bin/dhcp6/dhcp6_srv.cc | 33 +++++++++++++++++++-----
src/bin/dhcp6/tests/dhcp6_srv_unittest.cc | 4 ---
src/lib/dhcpsrv/alloc_engine.cc | 22 +++++++++++++++-
src/lib/dhcpsrv/tests/alloc_engine_unittest.cc | 11 ++------
src/lib/hooks/server_hooks.cc | 10 +++++--
6 files changed, 58 insertions(+), 27 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc b/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc
index 0785757..2aa32c4 100644
--- a/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc
+++ b/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc
@@ -157,11 +157,6 @@ public:
}
virtual ~Dhcpv4SrvTest() {
-
- // Remove all registered hook points (it must be done even for tests that
- // do not use hooks as the base class - Dhcpv4Srv calls allocation engine
- // that registers hooks)
- isc::hooks::ServerHooks::getServerHooks().reset();
}
/// @brief Add 'Parameter Request List' option to the packet.
diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc
index 57497c8..9da17c6 100644
--- a/src/bin/dhcp6/dhcp6_srv.cc
+++ b/src/bin/dhcp6/dhcp6_srv.cc
@@ -56,6 +56,30 @@ using namespace isc::hooks;
using namespace isc::util;
using namespace std;
+namespace {
+
+/// Structure that holds registered hook indexes
+struct Dhcp6Hooks {
+ int hook_index_pkt6_receive_; ///< index for "pkt6_receive" hook point
+ int hook_index_subnet6_select_; ///< index for "subnet6_select" hook point
+ int hook_index_pkt6_send_; ///< index for "pkt6_send" hook point
+
+ /// Constructor that registers hook points for DHCPv6 engine
+ Dhcp6Hooks() {
+ hook_index_pkt6_receive_ = HooksManager::registerHook("pkt6_receive");
+ hook_index_subnet6_select_ = HooksManager::registerHook("subnet6_select");
+ hook_index_pkt6_send_ = HooksManager::registerHook("pkt6_send");
+ }
+};
+
+// Declare a Hooks object. As this is outside any function or method, it
+// will be instantiated (and the constructor run) when the module is loaded.
+// As a result, the hook indexes will be defined before any method in this
+// module is called.
+Dhcp6Hooks Hooks;
+
+}; // anonymous namespace
+
namespace isc {
namespace dhcp {
@@ -112,9 +136,9 @@ Dhcpv6Srv::Dhcpv6Srv(uint16_t port)
alloc_engine_.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100));
// Register hook points
- hook_index_pkt6_receive_ = HooksManager::registerHook("pkt6_receive");
- hook_index_subnet6_select_ = HooksManager::registerHook("subnet6_select");
- hook_index_pkt6_send_ = HooksManager::registerHook("pkt6_send");
+ hook_index_pkt6_receive_ = Hooks.hook_index_pkt6_receive_;
+ hook_index_subnet6_select_ = Hooks.hook_index_subnet6_select_;
+ hook_index_pkt6_send_ = Hooks.hook_index_pkt6_send_;
/// @todo call loadLibraries() when handling configuration changes
vector<string> libraries; // no libraries at this time
@@ -133,9 +157,6 @@ Dhcpv6Srv::~Dhcpv6Srv() {
IfaceMgr::instance().closeSockets();
LeaseMgrFactory::destroy();
-
- /// @todo Unregister hooks once ServerHooks::deregisterHooks() becomes
- /// available
}
void Dhcpv6Srv::shutdown() {
diff --git a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
index 99b703e..12490c8 100644
--- a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
+++ b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
@@ -109,10 +109,6 @@ public:
}
virtual ~NakedDhcpv6Srv() {
- // Remove all registered hook points (it must be done even for tests that
- // do not use hooks as the base class - Dhcpv6Srv registers hooks)
- ServerHooks::getServerHooks().reset();
-
// Close the lease database
LeaseMgrFactory::destroy();
}
diff --git a/src/lib/dhcpsrv/alloc_engine.cc b/src/lib/dhcpsrv/alloc_engine.cc
index b798bf8..d08d6f6 100644
--- a/src/lib/dhcpsrv/alloc_engine.cc
+++ b/src/lib/dhcpsrv/alloc_engine.cc
@@ -26,6 +26,26 @@
using namespace isc::asiolink;
using namespace isc::hooks;
+namespace {
+
+/// Structure that holds registered hook indexes
+struct Dhcp6Hooks {
+ int hook_index_lease6_select_; ///< index for "lease6_receive" hook point
+
+ /// Constructor that registers hook points for AllocationEngine
+ Dhcp6Hooks() {
+ hook_index_lease6_select_ = HooksManager::registerHook("lease6_select");
+ }
+};
+
+// Declare a Hooks object. As this is outside any function or method, it
+// will be instantiated (and the constructor run) when the module is loaded.
+// As a result, the hook indexes will be defined before any method in this
+// module is called.
+Dhcp6Hooks Hooks;
+
+}; // anonymous namespace
+
namespace isc {
namespace dhcp {
@@ -167,7 +187,7 @@ AllocEngine::AllocEngine(AllocType engine_type, unsigned int attempts)
}
// Register hook points
- hook_index_lease6_select_ = ServerHooks::getServerHooks().registerHook("lease6_select");
+ hook_index_lease6_select_ = Hooks.hook_index_lease6_select_;
}
Lease6Ptr
diff --git a/src/lib/dhcpsrv/tests/alloc_engine_unittest.cc b/src/lib/dhcpsrv/tests/alloc_engine_unittest.cc
index b71ef98..775b626 100644
--- a/src/lib/dhcpsrv/tests/alloc_engine_unittest.cc
+++ b/src/lib/dhcpsrv/tests/alloc_engine_unittest.cc
@@ -112,10 +112,6 @@ public:
virtual ~AllocEngine6Test() {
factory_.destroy();
-
- // Remove all registered hook points (it must be done even for tests that
- // do not use hooks as the base class - Dhcpv6Srv registers hooks
- ServerHooks::getServerHooks().reset();
}
DuidPtr duid_; ///< client-identifier (value used in tests)
@@ -184,10 +180,6 @@ public:
virtual ~AllocEngine4Test() {
factory_.destroy();
-
- // Remove all registered hook points (it must be done even for tests that
- // do not use hooks as the base class - Dhcpv6Srv registers hooks
- ServerHooks::getServerHooks().reset();
}
ClientIdPtr clientid_; ///< Client-identifier (value used in tests)
@@ -1045,7 +1037,8 @@ public:
}
virtual ~HookAllocEngine6Test() {
-
+ HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts(
+ "lease6_select");
}
/// @brief clears out buffers, so callouts can store received arguments
diff --git a/src/lib/hooks/server_hooks.cc b/src/lib/hooks/server_hooks.cc
index 1a0b157..9f93db6 100644
--- a/src/lib/hooks/server_hooks.cc
+++ b/src/lib/hooks/server_hooks.cc
@@ -55,7 +55,8 @@ ServerHooks::registerHook(const string& name) {
inverse_hooks_[index] = name;
// Log it if debug is enabled
- LOG_DEBUG(hooks_logger, HOOKS_DBG_TRACE, HOOKS_HOOK_REGISTERED).arg(name);
+ /// @todo See todo comment in reset() below.
+ //LOG_DEBUG(hooks_logger, HOOKS_DBG_TRACE, HOOKS_HOOK_REGISTERED).arg(name);
// ... and return numeric index.
return (index);
@@ -85,7 +86,12 @@ ServerHooks::reset() {
// Log a warning - although this is done during testing, it should never be
// seen in a production system.
- LOG_WARN(hooks_logger, HOOKS_HOOK_LIST_RESET);
+ /// @todo Implement proper workaround here. The issue is when the first
+ /// module (e.g. Dhcp6Srv module) initializes global structure it calls
+ /// HooksManager::registerHooks() which in turn creates ServerHooks object.
+ /// Its constructor calls reset() method, but the loggers are not initialized
+ /// yet and exception is thrown.
+ //LOG_WARN(hooks_logger, HOOKS_HOOK_LIST_RESET);
}
// Find the name associated with a hook index.
More information about the bind10-changes
mailing list