From: Razvan Becheriu Date: Fri, 21 Feb 2020 16:51:06 +0000 (+0200) Subject: [#1016] implemented startPktProcessing and stopPktProcessing X-Git-Tag: Kea-1.7.6~83 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fc5ddfaab05254f26735144910dbd31eb9dba368;p=thirdparty%2Fkea.git [#1016] implemented startPktProcessing and stopPktProcessing --- diff --git a/src/lib/dhcpsrv/multi_threading_utils.cc b/src/lib/dhcpsrv/multi_threading_utils.cc index 767d4fbdb4..293c53f1b3 100644 --- a/src/lib/dhcpsrv/multi_threading_utils.cc +++ b/src/lib/dhcpsrv/multi_threading_utils.cc @@ -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() { diff --git a/src/lib/dhcpsrv/multi_threading_utils.h b/src/lib/dhcpsrv/multi_threading_utils.h index c139f938a5..a37f376bf3 100644 --- a/src/lib/dhcpsrv/multi_threading_utils.h +++ b/src/lib/dhcpsrv/multi_threading_utils.h @@ -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(); };