]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1016] addressed review
authorRazvan Becheriu <razvan@isc.org>
Sat, 7 Mar 2020 14:45:03 +0000 (16:45 +0200)
committerRazvan Becheriu <razvan@isc.org>
Sat, 7 Mar 2020 14:45:03 +0000 (16:45 +0200)
src/lib/util/multi_threading_mgr.cc
src/lib/util/multi_threading_mgr.h

index 3606e5cf2f9cdcf4829494ad365ba5cc8122173b..5ebfb110e697c1ff0e017fa7235fbca02e0f1e2b 100644 (file)
@@ -34,6 +34,7 @@ MultiThreadingMgr::setMode(bool enabled) {
 
 void
 MultiThreadingMgr::enterCriticalSection() {
+    stopPktProcessing();
     ++critical_section_count_;
 }
 
@@ -43,6 +44,7 @@ MultiThreadingMgr::exitCriticalSection() {
         isc_throw(InvalidOperation, "invalid negative value for override");
     }
     --critical_section_count_;
+    startPktProcessing();
 }
 
 bool
@@ -115,13 +117,11 @@ MultiThreadingMgr::startPktProcessing() {
 }
 
 MultiThreadingCriticalSection::MultiThreadingCriticalSection() {
-    MultiThreadingMgr::instance().stopPktProcessing();
     MultiThreadingMgr::instance().enterCriticalSection();
 }
 
 MultiThreadingCriticalSection::~MultiThreadingCriticalSection() {
     MultiThreadingMgr::instance().exitCriticalSection();
-    MultiThreadingMgr::instance().startPktProcessing();
 }
 
 }  // namespace util
index 62bfb225029ded6ba267e5d9a01b3e9b9a3bbc01..baced1ab61455844591891a5adaa7324807e37c4 100644 (file)
@@ -115,16 +115,6 @@ public:
     /// configured, 0 if auto scaling is desired
     void apply(bool enabled, uint32_t thread_count);
 
-    /// @brief Class method stopping and joining all threads of the pool.
-    ///
-    /// Stop the packet thread pool if running.
-    void stopPktProcessing();
-
-    /// @brief Class method (re)starting threads of the pool.
-    ///
-    /// Start the packet thread pool according to current configuration.
-    void startPktProcessing();
-
 protected:
 
     /// @brief Constructor.
@@ -135,6 +125,16 @@ protected:
 
 private:
 
+    /// @brief Class method stopping and joining all threads of the pool.
+    ///
+    /// Stop the packet thread pool if running.
+    void stopPktProcessing();
+
+    /// @brief Class method (re)starting threads of the pool.
+    ///
+    /// Start the packet thread pool according to current configuration.
+    void startPktProcessing();
+
     /// @brief The current multi-threading mode.
     ///
     /// The multi-threading flag: true if multi-threading is enabled, false