]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[947-mt-compatibility-for-hooks] Updated stat cmds 947-mt-compatibility-for-hooks
authorFrancis Dupont <fdupont@isc.org>
Thu, 7 Nov 2019 09:19:34 +0000 (10:19 +0100)
committerFrancis Dupont <fdupont@isc.org>
Thu, 7 Nov 2019 09:19:34 +0000 (10:19 +0100)
src/hooks/dhcp/stat_cmds/stat_cmds.cc
src/hooks/dhcp/stat_cmds/stat_cmds.dox
src/hooks/dhcp/stat_cmds/stat_cmds_callouts.cc

index 02f0b445eca44c599036f6eaa9a36885081650a3..f99c7b79412455c3f08fd34570996dcb73235e09 100644 (file)
@@ -12,6 +12,7 @@
 #include <dhcpsrv/cfgmgr.h>
 #include <dhcpsrv/lease_mgr.h>
 #include <dhcpsrv/lease_mgr_factory.h>
+#include <dhcpsrv/multi_threading_utils.h>
 #include <dhcpsrv/subnet_id.h>
 #include <hooks/hooks.h>
 #include <exceptions/exceptions.h>
@@ -661,15 +662,19 @@ LeaseStatCmdsImpl::getSubnetStat(const SubnetID& subnet_id, const std::string& n
     return (0);
 }
 
+// Using a critical section to avoid any changes in parallel.
+
 int
 StatCmds::statLease4GetHandler(CalloutHandle& handle) {
     LeaseStatCmdsImpl impl;
+    MultiThreadingCriticalSection sc;
     return(impl.statLease4GetHandler(handle));
 }
 
 int
 StatCmds::statLease6GetHandler(CalloutHandle& handle) {
     LeaseStatCmdsImpl impl;
+    MultiThreadingCriticalSection sc;
     return(impl.statLease6GetHandler(handle));
 }
 
index e267e3c35055c48d611603621c8f8dbd6d9f6e5d..34ac249ad221d2e4f503c6b3c776b336904cf29a 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2018-2019 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
@@ -198,8 +198,9 @@ and DHCPv6 response might look like this:
 
 @section stat_cmdsMTCompatibility Multi-Threading Compatibility
 
-The Stat Commands Hook library currently reports it is not
-compatible with multi-threading. This will be revisited as there is
-no essential reason for such uncompatibility.
+The Stat Commands Hook library reports it is compatible with
+multi-threading. All commands are executed inside a critical section,
+i.e. with threads stopped. It makes sense to not have lease state
+changes when taking lease counts.
 
 */
index c4afeaeab9b7f5377d319f8aa7b134c6c0a02607..ea8026124f0d76bad3da7a57b2d07952fc9492a8 100644 (file)
@@ -63,12 +63,9 @@ int unload() {
 
 /// @brief This function is called to know the multi-threading compatibility.
 ///
-/// @note: this should be revisited as the library is not essentially
-/// uncompatible.
-///
-/// @return 0 which means not compatible with multi-threading.
+/// @return 1 which means compatible with multi-threading.
 int multi_threading_compatible() {
-    return (0);
+    return (1);
 }
 
 } // end extern "C"