From: Francis Dupont Date: Tue, 5 Nov 2019 14:51:38 +0000 (+0100) Subject: [970-implement-multi-threading-critical-section] Removed the enabled_ local copy... X-Git-Tag: Kea-1.7.2~85 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=00fd7bcdfd55796e458e8bca438b6e42139dc6b6;p=thirdparty%2Fkea.git [970-implement-multi-threading-critical-section] Removed the enabled_ local copy of the MT mode --- diff --git a/src/lib/dhcpsrv/multi_threading_utils.cc b/src/lib/dhcpsrv/multi_threading_utils.cc index 99d182dad7..e12c89c229 100644 --- a/src/lib/dhcpsrv/multi_threading_utils.cc +++ b/src/lib/dhcpsrv/multi_threading_utils.cc @@ -29,15 +29,14 @@ MultiThreadingCriticalSection::startPktProcessing() { "is not yet implemented"); } -MultiThreadingCriticalSection::MultiThreadingCriticalSection() - : enabled_(MultiThreadingMgr::instance().getMode()) { - if (enabled_) { +MultiThreadingCriticalSection::MultiThreadingCriticalSection() { + if (MultiThreadingMgr::instance().getMode()) { stopPktProcessing(); } } MultiThreadingCriticalSection::~MultiThreadingCriticalSection() { - if (enabled_) { + if (MultiThreadingMgr::instance().getMode()) { startPktProcessing(); } } diff --git a/src/lib/dhcpsrv/multi_threading_utils.h b/src/lib/dhcpsrv/multi_threading_utils.h index 87c6b55f2f..ef5615736f 100644 --- a/src/lib/dhcpsrv/multi_threading_utils.h +++ b/src/lib/dhcpsrv/multi_threading_utils.h @@ -12,7 +12,7 @@ namespace isc { namespace dhcp { -/// @note: everything here MUST be used only from the main thread. +/// @note: everything here MUST be used ONLY from the main thread. /// When called from a thread of the pool it can deadlock. /// @brief Function stopping and joining all threads of the pool. @@ -24,6 +24,9 @@ void stopPktProcessing(); void startPktProcessing(); /// @brief RAII class creating a critical section. +/// +/// @note: the multi-threading mode MUST NOT be changed in the RAII +/// @c MultiThreadingCriticalSection body. class MultiThreadingCriticalSection : public boost::noncopyable { public: /// @brief Constructor. @@ -41,10 +44,6 @@ public: /// @brief Class method (re)starting threads of the pool. /// @throw isc::NotImplemented until is implemented. static void startPktProcessing(); - -private: - /// @brief Local copy of the multi-threading mode. - bool enabled_; }; }