From: Francis Dupont Date: Thu, 7 Nov 2019 09:19:34 +0000 (+0100) Subject: [947-mt-compatibility-for-hooks] Updated stat cmds X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2F947-mt-compatibility-for-hooks;p=thirdparty%2Fkea.git [947-mt-compatibility-for-hooks] Updated stat cmds --- diff --git a/src/hooks/dhcp/stat_cmds/stat_cmds.cc b/src/hooks/dhcp/stat_cmds/stat_cmds.cc index 02f0b445ec..f99c7b7941 100644 --- a/src/hooks/dhcp/stat_cmds/stat_cmds.cc +++ b/src/hooks/dhcp/stat_cmds/stat_cmds.cc @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -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)); } diff --git a/src/hooks/dhcp/stat_cmds/stat_cmds.dox b/src/hooks/dhcp/stat_cmds/stat_cmds.dox index e267e3c350..34ac249ad2 100644 --- a/src/hooks/dhcp/stat_cmds/stat_cmds.dox +++ b/src/hooks/dhcp/stat_cmds/stat_cmds.dox @@ -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. */ diff --git a/src/hooks/dhcp/stat_cmds/stat_cmds_callouts.cc b/src/hooks/dhcp/stat_cmds/stat_cmds_callouts.cc index c4afeaeab9..ea8026124f 100644 --- a/src/hooks/dhcp/stat_cmds/stat_cmds_callouts.cc +++ b/src/hooks/dhcp/stat_cmds/stat_cmds_callouts.cc @@ -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"