]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3178] Different CS callback names
authorMarcin Siodelski <marcin@isc.org>
Thu, 7 Dec 2023 14:33:38 +0000 (15:33 +0100)
committerMarcin Siodelski <marcin@isc.org>
Fri, 5 Jan 2024 18:04:19 +0000 (19:04 +0100)
Different HA services register their critical sections under different
names.

src/hooks/dhcp/high_availability/ha_service.cc
src/hooks/dhcp/high_availability/ha_service.h

index 50eb531ecd395fb3803a38d66e506965370455e7..6455c192583362e40a40f52d0b90f54e85392857 100644 (file)
@@ -149,6 +149,13 @@ HAService::~HAService() {
     network_state_->enableService(getLocalOrigin());
 }
 
+std::string
+HAService::getCSCallbacksSetName() const {
+    std::ostringstream s;
+    s << "HA_MT_" << id_;
+    return (s.str());
+}
+
 void
 HAService::defineEvents() {
     StateModel::defineEvents();
@@ -3266,7 +3273,7 @@ HAService::checkPermissionsClientAndListener() {
 void
 HAService::startClientAndListener() {
     // Add critical section callbacks.
-    MultiThreadingMgr::instance().addCriticalSectionCallbacks("HA_MT",
+    MultiThreadingMgr::instance().addCriticalSectionCallbacks(getCSCallbacksSetName(),
         std::bind(&HAService::checkPermissionsClientAndListener, this),
         std::bind(&HAService::pauseClientAndListener, this),
         std::bind(&HAService::resumeClientAndListener, this));
@@ -3320,7 +3327,7 @@ HAService::resumeClientAndListener() {
 void
 HAService::stopClientAndListener() {
     // Remove critical section callbacks.
-    MultiThreadingMgr::instance().removeCriticalSectionCallbacks("HA_MT");
+    MultiThreadingMgr::instance().removeCriticalSectionCallbacks(getCSCallbacksSetName());
 
     if (client_) {
         client_->stop();
index b5dad367e56dd7929c9b63ee22ef7582596c304d..35f208ad9ad83030cd0fbd570b4c703deb4c9468 100644 (file)
@@ -147,6 +147,15 @@ private:
         return (dhcp::NetworkState::HA_REMOTE_COMMAND + id_);
     }
 
+    /// @brief Returns the name of the critical section callbacks set.
+    ///
+    /// This function is used internally during the registration and
+    /// deregistration of the critical section callbacks in the MT
+    /// manager.
+    ///
+    /// @return HA_MT_ plus service id.
+    std::string getCSCallbacksSetName() const;
+
     /// @brief Defines events used by the HA service.
     virtual void defineEvents();