From 00fd7bcdfd55796e458e8bca438b6e42139dc6b6 Mon Sep 17 00:00:00 2001 From: Francis Dupont Date: Tue, 5 Nov 2019 15:51:38 +0100 Subject: [PATCH] [970-implement-multi-threading-critical-section] Removed the enabled_ local copy of the MT mode --- src/lib/dhcpsrv/multi_threading_utils.cc | 7 +++---- src/lib/dhcpsrv/multi_threading_utils.h | 9 ++++----- 2 files changed, 7 insertions(+), 9 deletions(-) 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_; }; } -- 2.47.2