]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1016] implemented startPktProcessing and stopPktProcessing
authorRazvan Becheriu <razvan@isc.org>
Fri, 21 Feb 2020 16:51:06 +0000 (18:51 +0200)
committerRazvan Becheriu <razvan@isc.org>
Fri, 6 Mar 2020 11:05:59 +0000 (13:05 +0200)
src/lib/dhcpsrv/multi_threading_utils.cc
src/lib/dhcpsrv/multi_threading_utils.h

index 767d4fbdb4e03fb54ab6e7da876302bbc0790fdb..293c53f1b30c73813a6b858ec3afa6259c29c46d 100644 (file)
@@ -18,16 +18,20 @@ namespace dhcp {
 
 void
 MultiThreadingCriticalSection::stopPktProcessing() {
-    isc_throw(NotImplemented,
-              "MultiThreadingCriticalSection::stopPktProcessing "
-              "is not yet implemented");
+    auto& thread_pool = MultiThreadingMgr::instance().getPktThreadPool();
+    auto size = MultiThreadingMgr::instance().getPktThreadPoolSize();
+    if (size) {
+        thread_pool.stop();
+    }
 }
 
 void
 MultiThreadingCriticalSection::startPktProcessing() {
-    isc_throw(NotImplemented,
-              "MultiThreadingCriticalSection::startPktProcessing "
-              "is not yet implemented");
+    auto& thread_pool = MultiThreadingMgr::instance().getPktThreadPool();
+    auto size = MultiThreadingMgr::instance().getPktThreadPoolSize();
+    if (size) {
+        thread_pool.start(size);
+    }
 }
 
 MultiThreadingCriticalSection::MultiThreadingCriticalSection() {
index c139f938a55214ab4643a0ef2069b746fb86bb31..a37f376bf38da985dc9b45ebab7edbd1f7b59a13 100644 (file)
@@ -27,21 +27,29 @@ void startPktProcessing();
 ///
 /// @note: the multi-threading mode MUST NOT be changed in the RAII
 /// @c MultiThreadingCriticalSection body.
+/// @note: starting and stopping the packet thread pool should be handled
+/// in the main thread, if done on one of the processing threads will cause a
+/// dead-lock
 class MultiThreadingCriticalSection : public boost::noncopyable {
 public:
+
     /// @brief Constructor.
+    ///
     /// Entering the critical section.
     MultiThreadingCriticalSection();
 
     /// @brief Destructor.
+    ///
     /// Leaving the critical section.
     virtual ~MultiThreadingCriticalSection();
 
     /// @brief Class method stopping and joining all threads of the pool.
+    ///
     /// @throw isc::NotImplemented until is implemented.
     static void stopPktProcessing();
 
     /// @brief Class method (re)starting threads of the pool.
+    ///
     /// @throw isc::NotImplemented until is implemented.
     static void startPktProcessing();
 };