]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3143] backport #3111 to v2_4
authorRazvan Becheriu <razvan@isc.org>
Mon, 13 Nov 2023 09:26:51 +0000 (11:26 +0200)
committerRazvan Becheriu <razvan@isc.org>
Mon, 13 Nov 2023 13:40:51 +0000 (15:40 +0200)
14 files changed:
ChangeLog
src/lib/dhcpsrv/flq_allocator.cc
src/lib/dhcpsrv/flq_allocator.h
src/lib/dhcpsrv/memfile_lease_mgr.cc
src/lib/dhcpsrv/mysql_lease_mgr.cc
src/lib/dhcpsrv/pgsql_lease_mgr.cc
src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.cc
src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.h
src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc
src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc
src/lib/dhcpsrv/tests/pgsql_lease_mgr_unittest.cc
src/lib/dhcpsrv/tests/tracking_lease_mgr_unittest.cc
src/lib/dhcpsrv/tracking_lease_mgr.cc
src/lib/dhcpsrv/tracking_lease_mgr.h

index 5eb3e9d454c87a9fcd4a3ced876b2a7d056ad773..7364c98e7f02fe9883445859ca7569da776d4471 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2167.  [bug]           razvan
+       Fixed a race condition in free lease queue allocator.
+       (Gitlab #3111, #3143)
+
 Kea 2.4.0 (stable) released on July 05, 2023
 
 2166.  [build]         mgodzina
index e361c3b906b405f47ea4e4a17395c9976a78c985..8da982f6c1b9d08b00f9343c44171d6dbce893e4 100644 (file)
@@ -166,16 +166,13 @@ FreeLeaseQueueAllocator::initAfterConfigureInternal() {
     auto& lease_mgr = LeaseMgrFactory::instance();
     lease_mgr.registerCallback(TrackingLeaseMgr::TRACK_ADD_LEASE, FLQ_OWNER, subnet->getID(), pool_type_,
                                std::bind(&FreeLeaseQueueAllocator::addLeaseCallback, this,
-                                         std::placeholders::_1,
-                                         std::placeholders::_2));
+                                         std::placeholders::_1));
     lease_mgr.registerCallback(TrackingLeaseMgr::TRACK_UPDATE_LEASE, FLQ_OWNER, subnet->getID(), pool_type_,
                                std::bind(&FreeLeaseQueueAllocator::updateLeaseCallback, this,
-                                         std::placeholders::_1,
-                                         std::placeholders::_2));
+                                         std::placeholders::_1));
     lease_mgr.registerCallback(TrackingLeaseMgr::TRACK_DELETE_LEASE, FLQ_OWNER, subnet->getID(), pool_type_,
                                std::bind(&FreeLeaseQueueAllocator::deleteLeaseCallback, this,
-                                         std::placeholders::_1,
-                                         std::placeholders::_2));
+                                         std::placeholders::_1));
 }
 
 template<typename LeaseCollectionType>
@@ -298,12 +295,8 @@ FreeLeaseQueueAllocator::getLeasePool(const LeasePtr& lease) const {
 }
 
 void
-FreeLeaseQueueAllocator::addLeaseCallback(LeasePtr lease, bool mt_safe) {
-    if (!mt_safe) {
-        MultiThreadingLock lock(mutex_);
-        addLeaseCallbackInternal(lease);
-        return;
-    }
+FreeLeaseQueueAllocator::addLeaseCallback(LeasePtr lease) {
+    MultiThreadingLock lock(mutex_);
     addLeaseCallbackInternal(lease);
 }
 
@@ -316,16 +309,12 @@ FreeLeaseQueueAllocator::addLeaseCallbackInternal(LeasePtr lease) {
     if (!pool) {
         return;
     }
-   getPoolState(pool)->deleteFreeLease(lease->addr_);
+    getPoolState(pool)->deleteFreeLease(lease->addr_);
 }
 
 void
-FreeLeaseQueueAllocator::updateLeaseCallback(LeasePtr lease, bool mt_safe) {
-    if (!mt_safe) {
-        MultiThreadingLock lock(mutex_);
-        updateLeaseCallbackInternal(lease);
-        return;
-    }
+FreeLeaseQueueAllocator::updateLeaseCallback(LeasePtr lease) {
+    MultiThreadingLock lock(mutex_);
     updateLeaseCallbackInternal(lease);
 }
 
@@ -344,12 +333,8 @@ FreeLeaseQueueAllocator::updateLeaseCallbackInternal(LeasePtr lease) {
 }
 
 void
-FreeLeaseQueueAllocator::deleteLeaseCallback(LeasePtr lease, bool mt_safe) {
-    if (!mt_safe) {
-        MultiThreadingLock lock(mutex_);
-        deleteLeaseCallbackInternal(lease);
-        return;
-    }
+FreeLeaseQueueAllocator::deleteLeaseCallback(LeasePtr lease) {
+    MultiThreadingLock lock(mutex_);
     deleteLeaseCallbackInternal(lease);
 }
 
index e001c95d5e14d3b778efd4b326be0e9a63e1d8ec..026ccc3fa918b4e3cdd9add53f607ddc4350e9cd 100644 (file)
@@ -142,9 +142,7 @@ private:
     /// Removes the lease from the free lease queue.
     ///
     /// @param lease added lease.
-    /// @param mt_safe a boolean flag indicating if the callback
-    /// has been invoked in the MT-safe context.
-    void addLeaseCallback(LeasePtr lease, bool mt_safe);
+    void addLeaseCallback(LeasePtr lease);
 
     /// @brief Thread unsafe callback for adding a lease.
     ///
@@ -160,9 +158,7 @@ private:
     /// the lease is removed from the free lease queue, if exists.
     ///
     /// @param lease updated lease.
-    /// @param mt_safe a boolean flag indicating if the callback
-    /// has been invoked in the MT-safe context.
-    void updateLeaseCallback(LeasePtr lease, bool mt_safe);
+    void updateLeaseCallback(LeasePtr lease);
 
     /// @brief Thread unsafe callback for updating a lease.
     ///
@@ -178,9 +174,7 @@ private:
     /// Adds the lease to the free lease queue.
     ///
     /// @param lease deleted lease.
-    /// @param mt_safe a boolean flag indicating if the callback
-    /// has been invoked in the MT-safe context.
-    void deleteLeaseCallback(LeasePtr lease, bool mt_safe);
+    void deleteLeaseCallback(LeasePtr lease);
 
     /// @brief Thread unsafe callback for updating a lease.
     ///
index 24bdc170f29498b5b2dcaf0fc0f6238987b311bf..b31617d08b8bcb01520ad412f48daca2f6346646 100644 (file)
@@ -1065,7 +1065,7 @@ Memfile_LeaseMgr::addLeaseInternal(const Lease4Ptr& lease) {
 
     // Run installed callbacks.
     if (hasCallbacks()) {
-        trackAddLease(lease, true);
+        trackAddLease(lease);
     }
 
     return (true);
@@ -1114,7 +1114,7 @@ Memfile_LeaseMgr::addLeaseInternal(const Lease6Ptr& lease) {
 
     // Run installed callbacks.
     if (hasCallbacks()) {
-        trackAddLease(lease, true);
+        trackAddLease(lease);
     }
 
     return (true);
@@ -1800,7 +1800,7 @@ Memfile_LeaseMgr::updateLease4Internal(const Lease4Ptr& lease) {
 
     // Run installed callbacks.
     if (hasCallbacks()) {
-        trackUpdateLease(lease, true);
+        trackUpdateLease(lease);
     }
 }
 
@@ -1880,7 +1880,7 @@ Memfile_LeaseMgr::updateLease6Internal(const Lease6Ptr& lease) {
 
     // Run installed callbacks.
     if (hasCallbacks()) {
-        trackUpdateLease(lease, true);
+        trackUpdateLease(lease);
     }
 }
 
@@ -1929,7 +1929,7 @@ Memfile_LeaseMgr::deleteLeaseInternal(const Lease4Ptr& lease) {
 
         // Run installed callbacks.
         if (hasCallbacks()) {
-            trackDeleteLease(lease, true);
+            trackDeleteLease(lease);
         }
 
         return (true);
@@ -1988,7 +1988,7 @@ Memfile_LeaseMgr::deleteLeaseInternal(const Lease6Ptr& lease) {
 
         // Run installed callbacks.
         if (hasCallbacks()) {
-            trackDeleteLease(lease, true);
+            trackDeleteLease(lease);
         }
 
         return (true);
index a9f0f15970b31599d6d9626bb4e949c735f4a00b..93198009d1368ec5504ab7024d8d5de6431c5213 100644 (file)
@@ -2338,7 +2338,7 @@ MySqlLeaseMgr::addLease(const Lease4Ptr& lease) {
 
     // Run installed callbacks.
     if (hasCallbacks()) {
-        trackAddLease(lease, false);
+        trackAddLease(lease);
     }
 
     return (result);
@@ -2366,7 +2366,7 @@ MySqlLeaseMgr::addLease(const Lease6Ptr& lease) {
 
     // Run installed callbacks.
     if (hasCallbacks()) {
-        trackAddLease(lease, false);
+        trackAddLease(lease);
     }
 
     return (result);
@@ -3242,7 +3242,7 @@ MySqlLeaseMgr::updateLease4(const Lease4Ptr& lease) {
 
     // Run installed callbacks.
     if (hasCallbacks()) {
-        trackUpdateLease(lease, false);
+        trackUpdateLease(lease);
     }
 }
 
@@ -3302,7 +3302,7 @@ MySqlLeaseMgr::updateLease6(const Lease6Ptr& lease) {
 
     // Run installed callbacks.
     if (hasCallbacks()) {
-        trackUpdateLease(lease, false);
+        trackUpdateLease(lease);
     }
 }
 
@@ -3366,7 +3366,7 @@ MySqlLeaseMgr::deleteLease(const Lease4Ptr& lease) {
     // Check success case first as it is the most likely outcome.
     if (affected_rows == 1) {
         if (hasCallbacks()) {
-            trackDeleteLease(lease, false);
+            trackDeleteLease(lease);
         }
         return (true);
     }
@@ -3427,7 +3427,7 @@ MySqlLeaseMgr::deleteLease(const Lease6Ptr& lease) {
     // Check success case first as it is the most likely outcome.
     if (affected_rows == 1) {
         if (hasCallbacks()) {
-            trackDeleteLease(lease, false);
+            trackDeleteLease(lease);
         }
         return (true);
     }
index 6ee99d674586169c3348c3e34ab69185c3de60b4..28c4109e4bbc56d389fdead5a7188704c056b6c9 100644 (file)
@@ -1749,7 +1749,7 @@ PgSqlLeaseMgr::addLease(const Lease4Ptr& lease) {
 
     // Run installed callbacks.
     if (hasCallbacks()) {
-        trackAddLease(lease, false);
+        trackAddLease(lease);
     }
 
     return (result);
@@ -1776,7 +1776,7 @@ PgSqlLeaseMgr::addLease(const Lease6Ptr& lease) {
 
     // Run installed callbacks.
     if (hasCallbacks()) {
-        trackAddLease(lease, false);
+        trackAddLease(lease);
     }
 
     return (result);
@@ -2433,7 +2433,7 @@ PgSqlLeaseMgr::updateLease4(const Lease4Ptr& lease) {
 
     // Run installed callbacks.
     if (hasCallbacks()) {
-        trackUpdateLease(lease, false);
+        trackUpdateLease(lease);
     }
 }
 
@@ -2475,7 +2475,7 @@ PgSqlLeaseMgr::updateLease6(const Lease6Ptr& lease) {
 
     // Run installed callbacks.
     if (hasCallbacks()) {
-        trackUpdateLease(lease, false);
+        trackUpdateLease(lease);
     }
 }
 
@@ -2526,7 +2526,7 @@ PgSqlLeaseMgr::deleteLease(const Lease4Ptr& lease) {
     // Check success case first as it is the most likely outcome.
     if (affected_rows == 1) {
         if (hasCallbacks()) {
-            trackDeleteLease(lease, false);
+            trackDeleteLease(lease);
         }
         return (true);
     }
@@ -2574,7 +2574,7 @@ PgSqlLeaseMgr::deleteLease(const Lease6Ptr& lease) {
     // Check success case first as it is the most likely outcome.
     if (affected_rows == 1) {
         if (hasCallbacks()) {
-            trackDeleteLease(lease, false);
+            trackDeleteLease(lease);
         }
         return (true);
     }
index 458fc95223cd3a4b8fa6fc23a0bcde0895f13980..0db51bf63eb7024141b4cb5f01e357ed6fad3dae 100644 (file)
@@ -2992,9 +2992,9 @@ GenericLeaseMgrTest::makeLease6(const Lease::Type& type,
 
 void
 GenericLeaseMgrTest::logCallback(TrackingLeaseMgr::CallbackType type, SubnetID subnet_id,
-                                 LeasePtr lease, bool mt_safe) {
+                                 LeasePtr lease) {
     auto locked = (lmptr_ ? lmptr_->isLocked(lease) : false);
-    logs_.push_back(Log{type, subnet_id, lease, mt_safe, locked});
+    logs_.push_back(Log{type, subnet_id, lease, locked});
 }
 
 int
@@ -4244,16 +4244,14 @@ GenericLeaseMgrTest::testClassLeaseCount6(Lease::Type ltype) {
 }
 
 void
-GenericLeaseMgrTest::testTrackAddLease4(bool expect_locked, bool expect_mt_safe) {
+GenericLeaseMgrTest::testTrackAddLease4(bool expect_locked) {
     // Register a callback for all subnets.
     lmptr_->registerCallback(TrackingLeaseMgr::TRACK_ADD_LEASE, "flq",
                              SUBNET_ID_GLOBAL, Lease::TYPE_V4,
                              std::bind(&GenericLeaseMgrTest::logCallback,
                                        this,
                                        TrackingLeaseMgr::TRACK_ADD_LEASE,
-                                       SUBNET_ID_GLOBAL,
-                                       ph::_1,
-                                       ph::_2));
+                                       SUBNET_ID_GLOBAL, ph::_1));
     // Add a lease. It should trigger the callback.
     Lease4Ptr lease = initializeLease4(straddress4_[1]);
     EXPECT_TRUE(lmptr_->addLease(lease));
@@ -4268,31 +4266,20 @@ GenericLeaseMgrTest::testTrackAddLease4(bool expect_locked, bool expect_mt_safe)
     } else {
         EXPECT_FALSE(logs_[0].locked);
     }
-    // This flag should be set to true for the Memfile backends.
-    // It should be false for other backends. If the backends do
-    // not provide the MT-safe context, the callbacks must protect
-    // against the concurrent access on their own.
-    if (expect_mt_safe) {
-        EXPECT_TRUE(logs_[0].mt_safe);
-    } else {
-        EXPECT_FALSE(logs_[0].mt_safe);
-    }
 
     // The lease locks should have been released.
     EXPECT_FALSE(lmptr_->isLocked(lease));
 }
 
 void
-GenericLeaseMgrTest::testTrackAddLeaseNA(bool expect_locked, bool expect_mt_safe) {
+GenericLeaseMgrTest::testTrackAddLeaseNA(bool expect_locked) {
     // Register a callback for all subnets.
     lmptr_->registerCallback(TrackingLeaseMgr::TRACK_ADD_LEASE, "flq",
                              SUBNET_ID_GLOBAL, Lease::TYPE_NA,
                              std::bind(&GenericLeaseMgrTest::logCallback,
                                        this,
                                        TrackingLeaseMgr::TRACK_ADD_LEASE,
-                                       SUBNET_ID_GLOBAL,
-                                       ph::_1,
-                                       ph::_2));
+                                       SUBNET_ID_GLOBAL, ph::_1));
     // Add a lease. It should trigger the callback.
     Lease6Ptr lease = initializeLease6(straddress6_[0]);
     EXPECT_TRUE(lmptr_->addLease(lease));
@@ -4307,31 +4294,20 @@ GenericLeaseMgrTest::testTrackAddLeaseNA(bool expect_locked, bool expect_mt_safe
     } else {
         EXPECT_FALSE(logs_[0].locked);
     }
-    // This flag should be set to true for the Memfile backends.
-    // It should be false for other backends. If the backends do
-    // not provide the MT-safe context, the callbacks must protect
-    // against the concurrent access on their own.
-    if (expect_mt_safe) {
-        EXPECT_TRUE(logs_[0].mt_safe);
-    } else {
-        EXPECT_FALSE(logs_[0].mt_safe);
-    }
 
     // The lease locks should have been released.
     EXPECT_FALSE(lmptr_->isLocked(lease));
 }
 
 void
-GenericLeaseMgrTest::testTrackAddLeasePD(bool expect_locked, bool expect_mt_safe) {
+GenericLeaseMgrTest::testTrackAddLeasePD(bool expect_locked) {
     // Register a callback for all subnets.
     lmptr_->registerCallback(TrackingLeaseMgr::TRACK_ADD_LEASE, "flq",
                              SUBNET_ID_GLOBAL, Lease::TYPE_PD,
                              std::bind(&GenericLeaseMgrTest::logCallback,
                                        this,
                                        TrackingLeaseMgr::TRACK_ADD_LEASE,
-                                       SUBNET_ID_GLOBAL,
-                                       ph::_1,
-                                       ph::_2));
+                                       SUBNET_ID_GLOBAL, ph::_1));
     // Add a lease. It should trigger the callback.
     Lease6Ptr lease = initializeLease6(straddress6_[2]);
     EXPECT_TRUE(lmptr_->addLease(lease));
@@ -4346,22 +4322,13 @@ GenericLeaseMgrTest::testTrackAddLeasePD(bool expect_locked, bool expect_mt_safe
     } else {
         EXPECT_FALSE(logs_[0].locked);
     }
-    // This flag should be set to true for the Memfile backends.
-    // It should be false for other backends. If the backends do
-    // not provide the MT-safe context, the callbacks must protect
-    // against the concurrent access on their own.
-    if (expect_mt_safe) {
-        EXPECT_TRUE(logs_[0].mt_safe);
-    } else {
-        EXPECT_FALSE(logs_[0].mt_safe);
-    }
 
     // The lease locks should have been released.
     EXPECT_FALSE(lmptr_->isLocked(lease));
 }
 
 void
-GenericLeaseMgrTest::testTrackUpdateLease4(bool expect_locked, bool expect_mt_safe) {
+GenericLeaseMgrTest::testTrackUpdateLease4(bool expect_locked) {
     // Register a callback for all subnets.
     lmptr_->registerCallback(TrackingLeaseMgr::TRACK_UPDATE_LEASE, "flq",
                              SUBNET_ID_GLOBAL,
@@ -4369,9 +4336,7 @@ GenericLeaseMgrTest::testTrackUpdateLease4(bool expect_locked, bool expect_mt_sa
                              std::bind(&GenericLeaseMgrTest::logCallback,
                                        this,
                                        TrackingLeaseMgr::TRACK_UPDATE_LEASE,
-                                       SUBNET_ID_GLOBAL,
-                                       ph::_1,
-                                       ph::_2));
+                                       SUBNET_ID_GLOBAL, ph::_1));
     // Add a lease.
     Lease4Ptr lease = initializeLease4(straddress4_[1]);
     EXPECT_TRUE(lmptr_->addLease(lease));
@@ -4389,31 +4354,20 @@ GenericLeaseMgrTest::testTrackUpdateLease4(bool expect_locked, bool expect_mt_sa
     } else {
         EXPECT_FALSE(logs_[0].locked);
     }
-    // This flag should be set to true for the Memfile backends.
-    // It should be false for other backends. If the backends do
-    // not provide the MT-safe context, the callbacks must protect
-    // against the concurrent access on their own.
-    if (expect_mt_safe) {
-        EXPECT_TRUE(logs_[0].mt_safe);
-    } else {
-        EXPECT_FALSE(logs_[0].mt_safe);
-    }
 
     // The lease locks should have been released.
     EXPECT_FALSE(lmptr_->isLocked(lease));
 }
 
 void
-GenericLeaseMgrTest::testTrackUpdateLeaseNA(bool expect_locked, bool expect_mt_safe) {
+GenericLeaseMgrTest::testTrackUpdateLeaseNA(bool expect_locked) {
     // Register a callback for all subnets.
     lmptr_->registerCallback(TrackingLeaseMgr::TRACK_UPDATE_LEASE, "flq",
                              SUBNET_ID_GLOBAL, Lease::TYPE_NA,
                              std::bind(&GenericLeaseMgrTest::logCallback,
                                        this,
                                        TrackingLeaseMgr::TRACK_UPDATE_LEASE,
-                                       SUBNET_ID_GLOBAL,
-                                       ph::_1,
-                                       ph::_2));
+                                       SUBNET_ID_GLOBAL, ph::_1));
     // Add a lease.
     Lease6Ptr lease = initializeLease6(straddress6_[0]);
     EXPECT_TRUE(lmptr_->addLease(lease));
@@ -4431,31 +4385,20 @@ GenericLeaseMgrTest::testTrackUpdateLeaseNA(bool expect_locked, bool expect_mt_s
     } else {
         EXPECT_FALSE(logs_[0].locked);
     }
-    // This flag should be set to true for the Memfile backends.
-    // It should be false for other backends. If the backends do
-    // not provide the MT-safe context, the callbacks must protect
-    // against the concurrent access on their own.
-    if (expect_mt_safe) {
-        EXPECT_TRUE(logs_[0].mt_safe);
-    } else {
-        EXPECT_FALSE(logs_[0].mt_safe);
-    }
 
     // The lease locks should have been released.
     EXPECT_FALSE(lmptr_->isLocked(lease));
 }
 
 void
-GenericLeaseMgrTest::testTrackUpdateLeasePD(bool expect_locked, bool expect_mt_safe) {
+GenericLeaseMgrTest::testTrackUpdateLeasePD(bool expect_locked) {
     // Register a callback for all subnets.
     lmptr_->registerCallback(TrackingLeaseMgr::TRACK_UPDATE_LEASE, "flq",
                              SUBNET_ID_GLOBAL, Lease::TYPE_PD,
                              std::bind(&GenericLeaseMgrTest::logCallback,
                                        this,
                                        TrackingLeaseMgr::TRACK_UPDATE_LEASE,
-                                       SUBNET_ID_GLOBAL,
-                                       ph::_1,
-                                       ph::_2));
+                                       SUBNET_ID_GLOBAL, ph::_1));
     // Add a lease.
     Lease6Ptr lease = initializeLease6(straddress6_[2]);
     EXPECT_TRUE(lmptr_->addLease(lease));
@@ -4473,31 +4416,20 @@ GenericLeaseMgrTest::testTrackUpdateLeasePD(bool expect_locked, bool expect_mt_s
     } else {
         EXPECT_FALSE(logs_[0].locked);
     }
-    // This flag should be set to true for the Memfile backends.
-    // It should be false for other backends. If the backends do
-    // not provide the MT-safe context, the callbacks must protect
-    // against the concurrent access on their own.
-    if (expect_mt_safe) {
-        EXPECT_TRUE(logs_[0].mt_safe);
-    } else {
-        EXPECT_FALSE(logs_[0].mt_safe);
-    }
 
     // The lease locks should have been released.
     EXPECT_FALSE(lmptr_->isLocked(lease));
 }
 
 void
-GenericLeaseMgrTest::testTrackDeleteLease4(bool expect_locked, bool expect_mt_safe) {
+GenericLeaseMgrTest::testTrackDeleteLease4(bool expect_locked) {
     // Register a callback for all subnets.
     lmptr_->registerCallback(TrackingLeaseMgr::TRACK_DELETE_LEASE, "flq",
                              SUBNET_ID_GLOBAL, Lease::TYPE_V4,
                              std::bind(&GenericLeaseMgrTest::logCallback,
                                        this,
                                        TrackingLeaseMgr::TRACK_DELETE_LEASE,
-                                       SUBNET_ID_GLOBAL,
-                                       ph::_1,
-                                       ph::_2));
+                                       SUBNET_ID_GLOBAL, ph::_1));
     // Add a lease.
     Lease4Ptr lease = initializeLease4(straddress4_[1]);
     EXPECT_TRUE(lmptr_->addLease(lease));
@@ -4515,31 +4447,20 @@ GenericLeaseMgrTest::testTrackDeleteLease4(bool expect_locked, bool expect_mt_sa
     } else {
         EXPECT_FALSE(logs_[0].locked);
     }
-    // This flag should be set to true for the Memfile backends.
-    // It should be false for other backends. If the backends do
-    // not provide the MT-safe context, the callbacks must protect
-    // against the concurrent access on their own.
-    if (expect_mt_safe) {
-        EXPECT_TRUE(logs_[0].mt_safe);
-    } else {
-        EXPECT_FALSE(logs_[0].mt_safe);
-    }
 
     // The lease locks should have been released.
     EXPECT_FALSE(lmptr_->isLocked(lease));
 }
 
 void
-GenericLeaseMgrTest::testTrackDeleteLeaseNA(bool expect_locked, bool expect_mt_safe) {
+GenericLeaseMgrTest::testTrackDeleteLeaseNA(bool expect_locked) {
     // Register a callback for all subnets.
     lmptr_->registerCallback(TrackingLeaseMgr::TRACK_DELETE_LEASE, "flq",
                              SUBNET_ID_GLOBAL, Lease::TYPE_NA,
                              std::bind(&GenericLeaseMgrTest::logCallback,
                                        this,
                                        TrackingLeaseMgr::TRACK_DELETE_LEASE,
-                                       SUBNET_ID_GLOBAL,
-                                       ph::_1,
-                                       ph::_2));
+                                       SUBNET_ID_GLOBAL, ph::_1));
     // Add a lease.
     Lease6Ptr lease = initializeLease6(straddress6_[0]);
     EXPECT_TRUE(lmptr_->addLease(lease));
@@ -4557,31 +4478,20 @@ GenericLeaseMgrTest::testTrackDeleteLeaseNA(bool expect_locked, bool expect_mt_s
     } else {
         EXPECT_FALSE(logs_[0].locked);
     }
-    // This flag should be set to true for the Memfile backends.
-    // It should be false for other backends. If the backends do
-    // not provide the MT-safe context, the callbacks must protect
-    // against the concurrent access on their own.
-    if (expect_mt_safe) {
-        EXPECT_TRUE(logs_[0].mt_safe);
-    } else {
-        EXPECT_FALSE(logs_[0].mt_safe);
-    }
 
     // The lease locks should have been released.
     EXPECT_FALSE(lmptr_->isLocked(lease));
 }
 
 void
-GenericLeaseMgrTest::testTrackDeleteLeasePD(bool expect_locked, bool expect_mt_safe) {
+GenericLeaseMgrTest::testTrackDeleteLeasePD(bool expect_locked) {
     // Register a callback for all subnets.
     lmptr_->registerCallback(TrackingLeaseMgr::TRACK_DELETE_LEASE, "flq",
                              SUBNET_ID_GLOBAL, Lease::TYPE_PD,
                              std::bind(&GenericLeaseMgrTest::logCallback,
                                        this,
                                        TrackingLeaseMgr::TRACK_DELETE_LEASE,
-                                       SUBNET_ID_GLOBAL,
-                                       ph::_1,
-                                       ph::_2));
+                                       SUBNET_ID_GLOBAL, ph::_1));
     // Add a lease.
     Lease6Ptr lease = initializeLease6(straddress6_[2]);
     EXPECT_TRUE(lmptr_->addLease(lease));
@@ -4599,15 +4509,6 @@ GenericLeaseMgrTest::testTrackDeleteLeasePD(bool expect_locked, bool expect_mt_s
     } else {
         EXPECT_FALSE(logs_[0].locked);
     }
-    // This flag should be set to true for the Memfile backends.
-    // It should be false for other backends. If the backends do
-    // not provide the MT-safe context, the callbacks must protect
-    // against the concurrent access on their own.
-    if (expect_mt_safe) {
-        EXPECT_TRUE(logs_[0].mt_safe);
-    } else {
-        EXPECT_FALSE(logs_[0].mt_safe);
-    }
 
     // The lease locks should have been released.
     EXPECT_FALSE(lmptr_->isLocked(lease));
@@ -4621,9 +4522,7 @@ GenericLeaseMgrTest::testRecreateWithCallbacks(const std::string& access) {
                              std::bind(&GenericLeaseMgrTest::logCallback,
                                        this,
                                        TrackingLeaseMgr::TRACK_ADD_LEASE,
-                                       0,
-                                       ph::_1,
-                                       ph::_2));
+                                       0, ph::_1));
 
     // Recreate the lease manager with the callbacks.
     ASSERT_NO_THROW(LeaseMgrFactory::recreate(access, true));
@@ -4645,9 +4544,7 @@ GenericLeaseMgrTest::testRecreateWithoutCallbacks(const std::string& access) {
                              std::bind(&GenericLeaseMgrTest::logCallback,
                                        this,
                                        TrackingLeaseMgr::TRACK_ADD_LEASE,
-                                       0,
-                                       ph::_1,
-                                       ph::_2));
+                                       0, ph::_1));
 
     // Recreate the lease manager without the callbacks.
     ASSERT_NO_THROW(LeaseMgrFactory::recreate(access, false));
index 50e4424729cb59c67ca28e13a25f4a407baa8819..47ec9e1bcbd40887840913ba4cf0eae8a2e154a0 100644 (file)
@@ -55,7 +55,6 @@ public:
         TrackingLeaseMgr::CallbackType type;
         SubnetID subnet_id;
         LeasePtr lease;
-        bool mt_safe;
         bool locked;
     } Log;
 
@@ -175,10 +174,8 @@ public:
     /// @param type callback type.
     /// @param subnet_id subnet identifier.
     /// @param lease lease instance.
-    /// @param mt a boolean flag indicating if the function has been called
-    /// in the thread-safe context.
     void logCallback(TrackingLeaseMgr::CallbackType type, SubnetID subnet_id,
-                     LeasePtr lease, bool mt_safe);
+                     LeasePtr lease);
 
     /// @brief Counts log entries.
     ///
@@ -579,81 +576,63 @@ public:
     ///
     /// @param expect_locked a boolean flag indicating if the test should
     /// expect that the lease is locked before the callback.
-    /// @param expect_mt_safe a boolean flag indicating if the test should
-    /// expect that the callbacks are called in the MT-safe context.
-    void testTrackAddLease4(bool expect_locked, bool expect_mt_safe);
+    void testTrackAddLease4(bool expect_locked);
 
     /// @brief Checks if the backends call the callbacks when an
     /// IPv6 address lease is added.
     ///
     /// @param expect_locked a boolean flag indicating if the test should
     /// expect that the lease is locked before the callback.
-    /// @param expect_mt_safe a boolean flag indicating if the test should
-    /// expect that the callbacks are called in the MT-safe context.
-    void testTrackAddLeaseNA(bool expect_locked, bool expect_mt_safe);
+    void testTrackAddLeaseNA(bool expect_locked);
 
     /// @brief Checks if the backends call the callbacks when an
     /// IPv6 prefix lease is added.
     ///
     /// @param expect_locked a boolean flag indicating if the test should
     /// expect that the lease is locked before the callback.
-    /// @param expect_mt_safe a boolean flag indicating if the test should
-    /// expect that the callbacks are called in the MT-safe context.
-    void testTrackAddLeasePD(bool expect_locked, bool expect_mt_safe);
+    void testTrackAddLeasePD(bool expect_locked);
 
     /// @brief Checks if the backends call the callbacks when an
     /// IPv4 lease is updated.
     ///
     /// @param expect_locked a boolean flag indicating if the test should
     /// expect that the lease is locked before the callback.
-    /// @param expect_mt_safe a boolean flag indicating if the test should
-    /// expect that the callbacks are called in the MT-safe context.
-    void testTrackUpdateLease4(bool expect_locked, bool expect_mt_safe);
+    void testTrackUpdateLease4(bool expect_locked);
 
     /// @brief Checks if the backends call the callbacks when an
     /// IPv6 address lease is updated.
     ///
     /// @param expect_locked a boolean flag indicating if the test should
     /// expect that the lease is locked before the callback.
-    /// @param expect_mt_safe a boolean flag indicating if the test should
-    /// expect that the callbacks are called in the MT-safe context.
-    void testTrackUpdateLeaseNA(bool expect_locked, bool expect_mt_safe);
+    void testTrackUpdateLeaseNA(bool expect_locked);
 
     /// @brief Checks if the backends call the callbacks when an
     /// IPv6 prefix lease is updated.
     ///
     /// @param expect_locked a boolean flag indicating if the test should
     /// expect that the lease is locked before the callback.
-    /// @param expect_mt_safe a boolean flag indicating if the test should
-    /// expect that the callbacks are called in the MT-safe context.
-    void testTrackUpdateLeasePD(bool expect_locked, bool expect_mt_safe);
+    void testTrackUpdateLeasePD(bool expect_locked);
 
     /// @brief Checks if the backends call the callbacks when an
     /// IPv4 lease is deleted.
     ///
     /// @param expect_locked a boolean flag indicating if the test should
     /// expect that the lease is locked before the callback.
-    /// @param expect_mt_safe a boolean flag indicating if the test should
-    /// expect that the callbacks are called in the MT-safe context.
-    void testTrackDeleteLease4(bool expect_locked, bool expect_mt_safe);
+    void testTrackDeleteLease4(bool expect_locked);
 
     /// @brief Checks if the backends call the callbacks when an
     /// IPv6 address lease is deleted.
     ///
     /// @param expect_locked a boolean flag indicating if the test should
     /// expect that the lease is locked before the callback.
-    /// @param expect_mt_safe a boolean flag indicating if the test should
-    /// expect that the callbacks are called in the MT-safe context.
-    void testTrackDeleteLeaseNA(bool expect_locked, bool expect_mt_safe);
+    void testTrackDeleteLeaseNA(bool expect_locked);
 
     /// @brief Checks if the backends call the callbacks when an
     /// IPv6 prefix lease is deleted.
     ///
     /// @param expect_locked a boolean flag indicating if the test should
     /// expect that the lease is locked before the callback.
-    /// @param expect_mt_safe a boolean flag indicating if the test should
-    /// expect that the callbacks are called in the MT-safe context.
-    void testTrackDeleteLeasePD(bool expect_locked, bool expect_mt_safe);
+    void testTrackDeleteLeasePD(bool expect_locked);
 
     /// @brief Checks that the lease manager can be recreated and its
     /// registered callbacks preserved, if desired.
index cd6e9162e1dab343d4340556287c11f57e842328..709b3ab6717555ffc80d5a3ec430d524fc5787c6 100644 (file)
@@ -4260,8 +4260,7 @@ TEST_F(MemfileLeaseMgrTest, buildExtendedInfoTables6rebuild) {
 /// IPv4 lease is added.
 TEST_F(MemfileLeaseMgrTest, trackAddLease4) {
     startBackend(V4);
-    // Expect that lease is not locked and the MT-safe context.
-    testTrackAddLease4(false, true);
+    testTrackAddLease4(false);
 }
 
 /// @brief Checks if the backends call the callbacks when an
@@ -4269,16 +4268,14 @@ TEST_F(MemfileLeaseMgrTest, trackAddLease4) {
 TEST_F(MemfileLeaseMgrTest, trackAddLease4MultiThreading) {
     startBackend(V4);
     MultiThreadingMgr::instance().setMode(true);
-    // Expect that lease is not locked and the MT-safe context.
-    testTrackAddLease4(false, true);
+    testTrackAddLease4(false);
 }
 
 /// @brief Checks if the backends call the callbacks when an
 /// IPv6 address lease is added.
 TEST_F(MemfileLeaseMgrTest, trackAddLeaseNA) {
     startBackend(V6);
-    // Expect that lease is not locked and the MT-safe context.
-    testTrackAddLeaseNA(false, true);
+    testTrackAddLeaseNA(false);
 }
 
 /// @brief Checks if the backends call the callbacks when an
@@ -4286,16 +4283,14 @@ TEST_F(MemfileLeaseMgrTest, trackAddLeaseNA) {
 TEST_F(MemfileLeaseMgrTest, trackAddLeaseNAMultiThreading) {
     startBackend(V6);
     MultiThreadingMgr::instance().setMode(true);
-    // Expect that lease is not locked and the MT-safe context.
-    testTrackAddLeaseNA(false, true);
+    testTrackAddLeaseNA(false);
 }
 
 /// @brief Checks if the backends call the callbacks when an
 /// IPv6 prefix lease is added.
 TEST_F(MemfileLeaseMgrTest, trackAddLeasePD) {
     startBackend(V6);
-    // Expect that lease is not locked and the MT-safe context.
-    testTrackAddLeasePD(false, true);
+    testTrackAddLeasePD(false);
 }
 
 /// @brief Checks if the backends call the callbacks when an
@@ -4303,16 +4298,14 @@ TEST_F(MemfileLeaseMgrTest, trackAddLeasePD) {
 TEST_F(MemfileLeaseMgrTest, trackAddLeasePDMultiThreading) {
     startBackend(V6);
     MultiThreadingMgr::instance().setMode(true);
-    // Expect that lease is not locked and the MT-safe context.
-    testTrackAddLeasePD(false, true);
+    testTrackAddLeasePD(false);
 }
 
 /// @brief Checks if the backends call the callbacks when an
 /// IPv4 lease is added.
 TEST_F(MemfileLeaseMgrTest, trackUpdateLease4) {
     startBackend(V4);
-    // Expect that lease is not locked and the MT-safe context.
-    testTrackUpdateLease4(false, true);
+    testTrackUpdateLease4(false);
 }
 
 /// @brief Checks if the backends call the callbacks when an
@@ -4320,16 +4313,14 @@ TEST_F(MemfileLeaseMgrTest, trackUpdateLease4) {
 TEST_F(MemfileLeaseMgrTest, trackUpdateLease4MultiThreading) {
     startBackend(V4);
     MultiThreadingMgr::instance().setMode(true);
-    // Expect that lease is not locked and the MT-safe context.
-    testTrackUpdateLease4(false, true);
+    testTrackUpdateLease4(false);
 }
 
 /// @brief Checks if the backends call the callbacks when an
 /// IPv6 address lease is updated.
 TEST_F(MemfileLeaseMgrTest, trackUpdateLeaseNA) {
     startBackend(V6);
-    // Expect that lease is not locked and the MT-safe context.
-    testTrackUpdateLeaseNA(false, true);
+    testTrackUpdateLeaseNA(false);
 }
 
 /// @brief Checks if the backends call the callbacks when an
@@ -4337,16 +4328,14 @@ TEST_F(MemfileLeaseMgrTest, trackUpdateLeaseNA) {
 TEST_F(MemfileLeaseMgrTest, trackUpdateLeaseNAMultiThreading) {
     startBackend(V6);
     MultiThreadingMgr::instance().setMode(true);
-    // Expect that lease is not locked and the MT-safe context.
-    testTrackUpdateLeaseNA(false, true);
+    testTrackUpdateLeaseNA(false);
 }
 
 /// @brief Checks if the backends call the callbacks when an
 /// IPv6 prefix lease is updated.
 TEST_F(MemfileLeaseMgrTest, trackUpdateLeasePD) {
     startBackend(V6);
-    // Expect that lease is not locked and the MT-safe context.
-    testTrackUpdateLeasePD(false, true);
+    testTrackUpdateLeasePD(false);
 }
 
 /// @brief Checks if the backends call the callbacks when an
@@ -4354,16 +4343,14 @@ TEST_F(MemfileLeaseMgrTest, trackUpdateLeasePD) {
 TEST_F(MemfileLeaseMgrTest, trackUpdateLeasePDMultiThreading) {
     startBackend(V6);
     MultiThreadingMgr::instance().setMode(true);
-    // Expect that lease is not locked and the MT-safe context.
-    testTrackUpdateLeasePD(false, true);
+    testTrackUpdateLeasePD(false);
 }
 
 /// @brief Checks if the backends call the callbacks when an
 /// IPv4 lease is added.
 TEST_F(MemfileLeaseMgrTest, trackDeleteLease4) {
     startBackend(V4);
-    // Expect that lease is not locked and the MT-safe context.
-    testTrackDeleteLease4(false, true);
+    testTrackDeleteLease4(false);
 }
 
 /// @brief Checks if the backends call the callbacks when an
@@ -4371,16 +4358,14 @@ TEST_F(MemfileLeaseMgrTest, trackDeleteLease4) {
 TEST_F(MemfileLeaseMgrTest, trackDeleteLease4MultiThreading) {
     startBackend(V4);
     MultiThreadingMgr::instance().setMode(true);
-    // Expect that lease is not locked and the MT-safe context.
-    testTrackDeleteLease4(false, true);
+    testTrackDeleteLease4(false);
 }
 
 /// @brief Checks if the backends call the callbacks when an
 /// IPv6 address lease is deleted.
 TEST_F(MemfileLeaseMgrTest, trackDeleteLeaseNA) {
     startBackend(V6);
-    // Expect that lease is not locked and the MT-safe context.
-    testTrackDeleteLeaseNA(false, true);
+    testTrackDeleteLeaseNA(false);
 }
 
 /// @brief Checks if the backends call the callbacks when an
@@ -4388,16 +4373,14 @@ TEST_F(MemfileLeaseMgrTest, trackDeleteLeaseNA) {
 TEST_F(MemfileLeaseMgrTest, trackDeleteLeaseNAMultiThreading) {
     startBackend(V6);
     MultiThreadingMgr::instance().setMode(true);
-    // Expect that lease is not locked and the MT-safe context.
-    testTrackDeleteLeaseNA(false, true);
+    testTrackDeleteLeaseNA(false);
 }
 
 /// @brief Checks if the backends call the callbacks when an
 /// IPv6 prefix lease is deleted.
 TEST_F(MemfileLeaseMgrTest, trackDeleteLeasePD) {
     startBackend(V6);
-    // Expect that lease is not locked and the MT-safe context.
-    testTrackDeleteLeasePD(false, true);
+    testTrackDeleteLeasePD(false);
 }
 
 /// @brief Checks if the backends call the callbacks when an
@@ -4405,8 +4388,7 @@ TEST_F(MemfileLeaseMgrTest, trackDeleteLeasePD) {
 TEST_F(MemfileLeaseMgrTest, trackDeleteLeasePDMultiThreading) {
     startBackend(V6);
     MultiThreadingMgr::instance().setMode(true);
-    // Expect that lease is not locked and the MT-safe context.
-    testTrackDeleteLeasePD(false, true);
+    testTrackDeleteLeasePD(false);
 }
 
 /// @brief Checks that the lease manager can be recreated and its
index eebe5a9b793bafd8d41e98a61a81c579fb2c8a84..b58e4b3b66a1e54f4adff24a35b2fbd7a04fe679 100644 (file)
@@ -1177,154 +1177,118 @@ TEST_F(MySqlLeaseMgrTest, checkLimits6) {
 /// @brief Checks if the backends call the callbacks when an
 /// IPv4 lease is added.
 TEST_F(MySqlLeaseMgrTest, trackAddLease4) {
-    // It is unnecessary to lock the lease in ST. The backend does not
-    // provide the MT-safe context for the callbacks.
-    testTrackAddLease4(false, false);
+    testTrackAddLease4(false);
 }
 
 /// @brief Checks if the backends call the callbacks when an
 /// IPv4 lease is added.
 TEST_F(MySqlLeaseMgrTest, trackAddLease4MultiThreading) {
     MultiThreadingMgr::instance().setMode(true);
-    // The lease should be locked in the MT mode. The backend does not
-    // provide an MT-safe context.
-    testTrackAddLease4(true, false);
+    testTrackAddLease4(true);
 }
 
 /// @brief Checks if the backends call the callbacks when an
 /// IPv6 address lease is added.
 TEST_F(MySqlLeaseMgrTest, trackAddLeaseNA) {
-    // It is unnecessary to lock the lease in ST. The backend does not
-    // provide the MT-safe context for the callbacks.
-    testTrackAddLeaseNA(false, false);
+    testTrackAddLeaseNA(false);
 }
 
 /// @brief Checks if the backends call the callbacks when an
 /// IPv6 address lease is added.
 TEST_F(MySqlLeaseMgrTest, trackAddLeaseNAMultiThreading) {
     MultiThreadingMgr::instance().setMode(true);
-    // The lease should be locked in the MT mode. The backend does not
-    // provide an MT-safe context.
-    testTrackAddLeaseNA(true, false);
+    testTrackAddLeaseNA(true);
 }
 
 /// @brief Checks if the backends call the callbacks when an
 /// IPv6 prefix lease is added.
 TEST_F(MySqlLeaseMgrTest, trackAddLeasePD) {
-    // It is unnecessary to lock the lease in ST. The backend does not
-    // provide the MT-safe context for the callbacks.
-    testTrackAddLeasePD(false, false);
+    testTrackAddLeasePD(false);
 }
 
 /// @brief Checks if the backends call the callbacks when an
 /// IPv6 prefix lease is added.
 TEST_F(MySqlLeaseMgrTest, trackAddLeasePDMultiThreading) {
     MultiThreadingMgr::instance().setMode(true);
-    // The lease should be locked in the MT mode. The backend does not
-    // provide an MT-safe context.
-    testTrackAddLeasePD(true, false);
+    testTrackAddLeasePD(true);
 }
 
 /// @brief Checks if the backends call the callbacks when an
 /// IPv4 lease is updated.
 TEST_F(MySqlLeaseMgrTest, trackUpdateLease4) {
-    // It is unnecessary to lock the lease in ST. The backend does not
-    // provide the MT-safe context for the callbacks.
-    testTrackUpdateLease4(false, false);
+    testTrackUpdateLease4(false);
 }
 
 /// @brief Checks if the backends call the callbacks when an
 /// IPv4 lease is updated.
 TEST_F(MySqlLeaseMgrTest, trackUpdateLease4MultiThreading) {
     MultiThreadingMgr::instance().setMode(true);
-    // The lease should be locked in the MT mode. The backend does not
-    // provide an MT-safe context.
-    testTrackUpdateLease4(true, false);
+    testTrackUpdateLease4(true);
 }
 
 /// @brief Checks if the backends call the callbacks when an
 /// IPv6 address lease is updated.
 TEST_F(MySqlLeaseMgrTest, trackUpdateLeaseNA) {
-    // It is unnecessary to lock the lease in ST. The backend does not
-    // provide the MT-safe context for the callbacks.
-    testTrackUpdateLeaseNA(false, false);
+    testTrackUpdateLeaseNA(false);
 }
 
 /// @brief Checks if the backends call the callbacks when an
 /// IPv6 address lease is updated.
 TEST_F(MySqlLeaseMgrTest, trackUpdateLeaseNAMultiThreading) {
     MultiThreadingMgr::instance().setMode(true);
-    // The lease should be locked in the MT mode. The backend does not
-    // provide an MT-safe context.
-    testTrackUpdateLeaseNA(true, false);
+    testTrackUpdateLeaseNA(true);
 }
 
 /// @brief Checks if the backends call the callbacks when an
 /// IPv6 prefix lease is updated.
 TEST_F(MySqlLeaseMgrTest, trackUpdateLeasePD) {
-    // It is unnecessary to lock the lease in ST. The backend does not
-    // provide the MT-safe context for the callbacks.
-    testTrackUpdateLeasePD(false, false);
+    testTrackUpdateLeasePD(false);
 }
 
 /// @brief Checks if the backends call the callbacks when an
 /// IPv6 prefix lease is updated.
 TEST_F(MySqlLeaseMgrTest, trackUpdateLeasePDMultiThreading) {
     MultiThreadingMgr::instance().setMode(true);
-    // The lease should be locked in the MT mode. The backend does not
-    // provide an MT-safe context.
-    testTrackUpdateLeasePD(true, false);
+    testTrackUpdateLeasePD(true);
 }
 
 /// @brief Checks if the backends call the callbacks when an
 /// IPv4 lease is deleted.
 TEST_F(MySqlLeaseMgrTest, trackDeleteLease4) {
-    // It is unnecessary to lock the lease in ST. The backend does not
-    // provide the MT-safe context for the callbacks.
-    testTrackDeleteLease4(false, false);
+    testTrackDeleteLease4(false);
 }
 
 /// @brief Checks if the backends call the callbacks when an
 /// IPv4 lease is deleted.
 TEST_F(MySqlLeaseMgrTest, trackDeleteLease4MultiThreading) {
     MultiThreadingMgr::instance().setMode(true);
-    // The lease should be locked in the MT mode. The backend does not
-    // provide an MT-safe context.
-    testTrackDeleteLease4(true, false);
+    testTrackDeleteLease4(true);
 }
 
 /// @brief Checks if the backends call the callbacks when an
 /// IPv6 address lease is deleted.
 TEST_F(MySqlLeaseMgrTest, trackDeleteLeaseNA) {
-    // It is unnecessary to lock the lease in ST. The backend does not
-    // provide the MT-safe context for the callbacks.
-    testTrackDeleteLeaseNA(false, false);
+    testTrackDeleteLeaseNA(false);
 }
 
 /// @brief Checks if the backends call the callbacks when an
 /// IPv6 address lease is deleted.
 TEST_F(MySqlLeaseMgrTest, trackDeleteLeaseNAMultiThreading) {
     MultiThreadingMgr::instance().setMode(true);
-    // The lease should be locked in the MT mode. The backend does not
-    // provide an MT-safe context.
-    testTrackDeleteLeaseNA(true, false);
+    testTrackDeleteLeaseNA(true);
 }
 
 /// @brief Checks if the backends call the callbacks when an
 /// IPv6 prefix lease is deleted.
 TEST_F(MySqlLeaseMgrTest, trackDeleteLeasePD) {
-    // It is unnecessary to lock the lease in ST. The backend does not
-    // provide the MT-safe context for the callbacks.
-    testTrackDeleteLeasePD(false, false);
+    testTrackDeleteLeasePD(false);
 }
 
 /// @brief Checks if the backends call the callbacks when an
 /// IPv6 prefix lease is deleted.
 TEST_F(MySqlLeaseMgrTest, trackDeleteLeasePDMultiThreading) {
     MultiThreadingMgr::instance().setMode(true);
-    // The lease should be locked in the MT mode. The backend does not
-    // provide an MT-safe context.
-    testTrackDeleteLeasePD(true, false);
+    testTrackDeleteLeasePD(true);
 }
 
 /// @brief Checks that the lease manager can be recreated and its
index 0045cefd74a2005176e9aa33ac8b9b0fe64e89fd..17a0087911b3249280765da1be21003d63d86b98 100644 (file)
@@ -1166,154 +1166,118 @@ TEST_F(PgSqlLeaseMgrTest, checkLimits6) {
 /// @brief Checks if the backends call the callbacks when an
 /// IPv4 lease is added.
 TEST_F(PgSqlLeaseMgrTest, trackAddLease4) {
-    // It is unnecessary to lock the lease in ST. The backend does not
-    // provide the MT-safe context for the callbacks.
-    testTrackAddLease4(false, false);
+    testTrackAddLease4(false);
 }
 
 /// @brief Checks if the backends call the callbacks when an
 /// IPv4 lease is added.
 TEST_F(PgSqlLeaseMgrTest, trackAddLease4MultiThreading) {
     MultiThreadingMgr::instance().setMode(true);
-    // The lease should be locked in the MT mode. The backend does not
-    // provide an MT-safe context.
-    testTrackAddLease4(true, false);
+    testTrackAddLease4(true);
 }
 
 /// @brief Checks if the backends call the callbacks when an
 /// IPv6 address lease is added.
 TEST_F(PgSqlLeaseMgrTest, trackAddLeaseNA) {
-    // It is unnecessary to lock the lease in ST. The backend does not
-    // provide the MT-safe context for the callbacks.
-    testTrackAddLeaseNA(false, false);
+    testTrackAddLeaseNA(false);
 }
 
 /// @brief Checks if the backends call the callbacks when an
 /// IPv6 address lease is added.
 TEST_F(PgSqlLeaseMgrTest, trackAddLeaseNAMultiThreading) {
     MultiThreadingMgr::instance().setMode(true);
-    // The lease should be locked in the MT mode. The backend does not
-    // provide an MT-safe context.
-    testTrackAddLeaseNA(true, false);
+    testTrackAddLeaseNA(true);
 }
 
 /// @brief Checks if the backends call the callbacks when an
 /// IPv6 prefix lease is added.
 TEST_F(PgSqlLeaseMgrTest, trackAddLeasePD) {
-    // It is unnecessary to lock the lease in ST. The backend does not
-    // provide the MT-safe context for the callbacks.
-    testTrackAddLeasePD(false, false);
+    testTrackAddLeasePD(false);
 }
 
 /// @brief Checks if the backends call the callbacks when an
 /// IPv6 prefix lease is added.
 TEST_F(PgSqlLeaseMgrTest, trackAddLeasePDMultiThreading) {
     MultiThreadingMgr::instance().setMode(true);
-    // The lease should be locked in the MT mode. The backend does not
-    // provide an MT-safe context.
-    testTrackAddLeasePD(true, false);
+    testTrackAddLeasePD(true);
 }
 
 /// @brief Checks if the backends call the callbacks when an
 /// IPv4 lease is updated.
 TEST_F(PgSqlLeaseMgrTest, trackUpdateLease4) {
-    // It is unnecessary to lock the lease in ST. The backend does not
-    // provide the MT-safe context for the callbacks.
-    testTrackUpdateLease4(false, false);
+    testTrackUpdateLease4(false);
 }
 
 /// @brief Checks if the backends call the callbacks when an
 /// IPv4 lease is updated.
 TEST_F(PgSqlLeaseMgrTest, trackUpdateLease4MultiThreading) {
     MultiThreadingMgr::instance().setMode(true);
-    // The lease should be locked in the MT mode. The backend does not
-    // provide an MT-safe context.
-    testTrackUpdateLease4(true, false);
+    testTrackUpdateLease4(true);
 }
 
 /// @brief Checks if the backends call the callbacks when an
 /// IPv6 address lease is updated.
 TEST_F(PgSqlLeaseMgrTest, trackUpdateLeaseNA) {
-    // It is unnecessary to lock the lease in ST. The backend does not
-    // provide the MT-safe context for the callbacks.
-    testTrackUpdateLeaseNA(false, false);
+    testTrackUpdateLeaseNA(false);
 }
 
 /// @brief Checks if the backends call the callbacks when an
 /// IPv6 address lease is updated.
 TEST_F(PgSqlLeaseMgrTest, trackUpdateLeaseNAMultiThreading) {
     MultiThreadingMgr::instance().setMode(true);
-    // The lease should be locked in the MT mode. The backend does not
-    // provide an MT-safe context.
-    testTrackUpdateLeaseNA(true, false);
+    testTrackUpdateLeaseNA(true);
 }
 
 /// @brief Checks if the backends call the callbacks when an
 /// IPv6 prefix lease is updated.
 TEST_F(PgSqlLeaseMgrTest, trackUpdateLeasePD) {
-    // It is unnecessary to lock the lease in ST. The backend does not
-    // provide the MT-safe context for the callbacks.
-    testTrackUpdateLeasePD(false, false);
+    testTrackUpdateLeasePD(false);
 }
 
 /// @brief Checks if the backends call the callbacks when an
 /// IPv6 prefix lease is updated.
 TEST_F(PgSqlLeaseMgrTest, trackUpdateLeasePDMultiThreading) {
     MultiThreadingMgr::instance().setMode(true);
-    // The lease should be locked in the MT mode. The backend does not
-    // provide an MT-safe context.
-    testTrackUpdateLeasePD(true, false);
+    testTrackUpdateLeasePD(true);
 }
 
 /// @brief Checks if the backends call the callbacks when an
 /// IPv4 lease is deleted.
 TEST_F(PgSqlLeaseMgrTest, trackDeleteLease4) {
-    // It is unnecessary to lock the lease in ST. The backend does not
-    // provide the MT-safe context for the callbacks.
-    testTrackDeleteLease4(false, false);
+    testTrackDeleteLease4(false);
 }
 
 /// @brief Checks if the backends call the callbacks when an
 /// IPv4 lease is deleted.
 TEST_F(PgSqlLeaseMgrTest, trackDeleteLease4MultiThreading) {
     MultiThreadingMgr::instance().setMode(true);
-    // The lease should be locked in the MT mode. The backend does not
-    // provide an MT-safe context.
-    testTrackDeleteLease4(true, false);
+    testTrackDeleteLease4(true);
 }
 
 /// @brief Checks if the backends call the callbacks when an
 /// IPv6 address lease is deleted.
 TEST_F(PgSqlLeaseMgrTest, trackDeleteLeaseNA) {
-    // It is unnecessary to lock the lease in ST. The backend does not
-    // provide the MT-safe context for the callbacks.
-    testTrackDeleteLeaseNA(false, false);
+    testTrackDeleteLeaseNA(false);
 }
 
 /// @brief Checks if the backends call the callbacks when an
 /// IPv6 address lease is deleted.
 TEST_F(PgSqlLeaseMgrTest, trackDeleteLeaseNAMultiThreading) {
     MultiThreadingMgr::instance().setMode(true);
-    // The lease should be locked in the MT mode. The backend does not
-    // provide an MT-safe context.
-    testTrackDeleteLeaseNA(true, false);
+    testTrackDeleteLeaseNA(true);
 }
 
 /// @brief Checks if the backends call the callbacks when an
 /// IPv6 prefix lease is deleted.
 TEST_F(PgSqlLeaseMgrTest, trackDeleteLeasePD) {
-    // It is unnecessary to lock the lease in ST. The backend does not
-    // provide the MT-safe context for the callbacks.
-    testTrackDeleteLeasePD(false, false);
+    testTrackDeleteLeasePD(false);
 }
 
 /// @brief Checks if the backends call the callbacks when an
 /// IPv6 prefix lease is deleted.
 TEST_F(PgSqlLeaseMgrTest, trackDeleteLeasePDMultiThreading) {
     MultiThreadingMgr::instance().setMode(true);
-    // The lease should be locked in the MT mode. The backend does not
-    // provide an MT-safe context.
-    testTrackDeleteLeasePD(true, false);
+    testTrackDeleteLeasePD(true);
 }
 
 /// @brief Checks that the lease manager can be recreated and its
index 1a58b197b1714c043a266e130e712208ab82bb17..1361c1c6dce6c376f6533440f509e56e88c12ba7 100644 (file)
@@ -105,50 +105,45 @@ TEST_F(TrackingLeaseMgrTest, registerCallbacks) {
                                          std::bind(&TrackingLeaseMgrTest::logCallback,
                                                    this,
                                                    TrackingLeaseMgr::TRACK_ADD_LEASE,
-                                                   SUBNET_ID_GLOBAL,
-                                                   ph::_1, ph::_2)));
+                                                   SUBNET_ID_GLOBAL, ph::_1)));
     // Callback for lease add and subnet id 1.
     EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_ADD_LEASE, "flq", 1,
                                          Lease::TYPE_V4,
                                          std::bind(&TrackingLeaseMgrTest::logCallback,
                                                    this,
                                                    TrackingLeaseMgr::TRACK_ADD_LEASE,
-                                                   1,
-                                                   ph::_1, ph::_2)));
+                                                   1, ph::_1)));
     // Callback for lease add and subnet id 2.
     EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_ADD_LEASE, "flq", 2,
                                          Lease::TYPE_V4,
                                          std::bind(&TrackingLeaseMgrTest::logCallback,
                                                    this,
                                                    TrackingLeaseMgr::TRACK_ADD_LEASE,
-                                                   1,
-                                                   ph::_1, ph::_2)));
+                                                   1, ph::_1)));
     // Callback for lease update and global subnet id.
     EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_UPDATE_LEASE, "flq",
                                          SUBNET_ID_GLOBAL, Lease::TYPE_V4,
                                          std::bind(&TrackingLeaseMgrTest::logCallback,
                                                    this,
                                                    TrackingLeaseMgr::TRACK_UPDATE_LEASE,
-                                                   SUBNET_ID_GLOBAL,
-                                                   ph::_1, ph::_2)));
+                                                   SUBNET_ID_GLOBAL, ph::_1)));
     // Callback for lease delete and global subnet id.
     EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_DELETE_LEASE, "flq",
                                          SUBNET_ID_GLOBAL, Lease::TYPE_V4,
                                          std::bind(&TrackingLeaseMgrTest::logCallback,
                                                    this,
                                                    TrackingLeaseMgr::TRACK_DELETE_LEASE,
-                                                   SUBNET_ID_GLOBAL,
-                                                   ph::_1, ph::_2)));
+                                                   SUBNET_ID_GLOBAL, ph::_1)));
 
     // This call should trigger the lease add callbacks for subnet id 0 and 1.
-    EXPECT_NO_THROW(mgr.trackAddLease(initializeLease(1, "192.0.2.1"), false));
+    EXPECT_NO_THROW(mgr.trackAddLease(initializeLease(1, "192.0.2.1")));
     EXPECT_EQ(2, logs_.size());
     EXPECT_EQ(1, countLogs(TrackingLeaseMgr::TRACK_ADD_LEASE, SUBNET_ID_GLOBAL, Lease::TYPE_V4));
     EXPECT_EQ(1, countLogs(TrackingLeaseMgr::TRACK_ADD_LEASE, 1, Lease::TYPE_V4));
 
     // This call should trigger the lease add callback for subnet id 0 only. That's
     // because we have no callback for the subnet id 3.
-    EXPECT_NO_THROW(mgr.trackAddLease(initializeLease(3, "192.0.2.1"), false));
+    EXPECT_NO_THROW(mgr.trackAddLease(initializeLease(3, "192.0.2.1")));
     EXPECT_EQ(3, logs_.size());
     EXPECT_EQ(2, countLogs(TrackingLeaseMgr::TRACK_ADD_LEASE, SUBNET_ID_GLOBAL, Lease::TYPE_V4));
 }
@@ -165,8 +160,7 @@ TEST_F(TrackingLeaseMgrTest, registerCallbacksConflicts) {
                                          std::bind(&TrackingLeaseMgrTest::logCallback,
                                                    this,
                                                    TrackingLeaseMgr::TRACK_ADD_LEASE,
-                                                   SUBNET_ID_GLOBAL,
-                                                   ph::_1, ph::_2)));
+                                                   SUBNET_ID_GLOBAL, ph::_1)));
 
     // Another attempt should fail.
     EXPECT_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_ADD_LEASE, "flq",
@@ -174,8 +168,7 @@ TEST_F(TrackingLeaseMgrTest, registerCallbacksConflicts) {
                                       std::bind(&TrackingLeaseMgrTest::logCallback,
                                                 this,
                                                 TrackingLeaseMgr::TRACK_ADD_LEASE,
-                                                SUBNET_ID_GLOBAL,
-                                                ph::_1, ph::_2)),
+                                                SUBNET_ID_GLOBAL, ph::_1)),
                  InvalidOperation);
 
     // It should succeed for a different owner.
@@ -185,8 +178,7 @@ TEST_F(TrackingLeaseMgrTest, registerCallbacksConflicts) {
                                          std::bind(&TrackingLeaseMgrTest::logCallback,
                                                    this,
                                                    TrackingLeaseMgr::TRACK_ADD_LEASE,
-                                                   SUBNET_ID_GLOBAL,
-                                                   ph::_1, ph::_2)));
+                                                   SUBNET_ID_GLOBAL, ph::_1)));
 
     // It should also succeed for a different subnet id.
     EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_ADD_LEASE, "qlf", 5,
@@ -194,8 +186,7 @@ TEST_F(TrackingLeaseMgrTest, registerCallbacksConflicts) {
                                          std::bind(&TrackingLeaseMgrTest::logCallback,
                                                    this,
                                                    TrackingLeaseMgr::TRACK_ADD_LEASE,
-                                                   5,
-                                                   ph::_1, ph::_2)));
+                                                   5, ph::_1)));
 
     // But, another attempt for the subnet id should fail.
     EXPECT_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_ADD_LEASE, "qlf", 5,
@@ -203,8 +194,7 @@ TEST_F(TrackingLeaseMgrTest, registerCallbacksConflicts) {
                                       std::bind(&TrackingLeaseMgrTest::logCallback,
                                                 this,
                                                 TrackingLeaseMgr::TRACK_ADD_LEASE,
-                                                5,
-                                                ph::_1, ph::_2)),
+                                                5, ph::_1)),
                  InvalidOperation);
 
     // However, changing a lease type should make it succeed.
@@ -213,8 +203,7 @@ TEST_F(TrackingLeaseMgrTest, registerCallbacksConflicts) {
                                       std::bind(&TrackingLeaseMgrTest::logCallback,
                                                 this,
                                                 TrackingLeaseMgr::TRACK_ADD_LEASE,
-                                                5,
-                                                ph::_1, ph::_2)));
+                                                5, ph::_1)));
 }
 
 /// Test invoking the registered lease add callbacks.
@@ -227,34 +216,31 @@ TEST_F(TrackingLeaseMgrTest, trackAddLeaseDifferentLeaseTypes) {
                                          std::bind(&TrackingLeaseMgrTest::logCallback,
                                                    this,
                                                    TrackingLeaseMgr::TRACK_ADD_LEASE,
-                                                   SUBNET_ID_GLOBAL,
-                                                   ph::_1, ph::_2)));
+                                                   SUBNET_ID_GLOBAL, ph::_1)));
 
     EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_ADD_LEASE, "flq",
                                          SUBNET_ID_GLOBAL, Lease::TYPE_NA,
                                          std::bind(&TrackingLeaseMgrTest::logCallback,
                                                    this,
                                                    TrackingLeaseMgr::TRACK_ADD_LEASE,
-                                                   SUBNET_ID_GLOBAL,
-                                                   ph::_1, ph::_2)));
+                                                   SUBNET_ID_GLOBAL, ph::_1)));
 
     EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_ADD_LEASE, "flq",
                                          SUBNET_ID_GLOBAL, Lease::TYPE_PD,
                                          std::bind(&TrackingLeaseMgrTest::logCallback,
                                                    this,
                                                    TrackingLeaseMgr::TRACK_ADD_LEASE,
-                                                   SUBNET_ID_GLOBAL,
-                                                   ph::_1, ph::_2)));
+                                                   SUBNET_ID_GLOBAL, ph::_1)));
 
-    EXPECT_NO_THROW(mgr.trackAddLease(initializeLease(1, "192.0.2.1"), false));
+    EXPECT_NO_THROW(mgr.trackAddLease(initializeLease(1, "192.0.2.1")));
     EXPECT_EQ(1, logs_.size());
     EXPECT_EQ(1, countLogs(TrackingLeaseMgr::TRACK_ADD_LEASE, SUBNET_ID_GLOBAL, Lease::TYPE_V4));
 
-    EXPECT_NO_THROW(mgr.trackAddLease(initializeLease(1, Lease::TYPE_NA, "2001:db8:1::1"), false));
+    EXPECT_NO_THROW(mgr.trackAddLease(initializeLease(1, Lease::TYPE_NA, "2001:db8:1::1")));
     EXPECT_EQ(2, logs_.size());
     EXPECT_EQ(1, countLogs(TrackingLeaseMgr::TRACK_ADD_LEASE, SUBNET_ID_GLOBAL, Lease::TYPE_NA));
 
-    EXPECT_NO_THROW(mgr.trackAddLease(initializeLease(1, Lease::TYPE_PD, "3000::"), false));
+    EXPECT_NO_THROW(mgr.trackAddLease(initializeLease(1, Lease::TYPE_PD, "3000::")));
     EXPECT_EQ(3, logs_.size());
     EXPECT_EQ(1, countLogs(TrackingLeaseMgr::TRACK_ADD_LEASE, SUBNET_ID_GLOBAL, Lease::TYPE_PD));
 }
@@ -269,24 +255,21 @@ TEST_F(TrackingLeaseMgrTest, trackUpdateLease) {
                                          std::bind(&TrackingLeaseMgrTest::logCallback,
                                                    this,
                                                    TrackingLeaseMgr::TRACK_ADD_LEASE,
-                                                   SUBNET_ID_GLOBAL,
-                                                   ph::_1, ph::_2)));
+                                                   SUBNET_ID_GLOBAL, ph::_1)));
     EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_UPDATE_LEASE, "flq",
                                          SUBNET_ID_GLOBAL,
                                          Lease::TYPE_V4,
                                          std::bind(&TrackingLeaseMgrTest::logCallback,
                                                    this,
                                                    TrackingLeaseMgr::TRACK_UPDATE_LEASE,
-                                                   SUBNET_ID_GLOBAL,
-                                                   ph::_1, ph::_2)));
+                                                   SUBNET_ID_GLOBAL, ph::_1)));
     EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_DELETE_LEASE, "flq",
                                          SUBNET_ID_GLOBAL, Lease::TYPE_V4,
                                          std::bind(&TrackingLeaseMgrTest::logCallback,
                                                    this,
                                                    TrackingLeaseMgr::TRACK_DELETE_LEASE,
-                                                   SUBNET_ID_GLOBAL,
-                                                   ph::_1, ph::_2)));
-    EXPECT_NO_THROW(mgr.trackUpdateLease(initializeLease(1, "192.0.2.1"), false));
+                                                   SUBNET_ID_GLOBAL, ph::_1)));
+    EXPECT_NO_THROW(mgr.trackUpdateLease(initializeLease(1, "192.0.2.1")));
     EXPECT_EQ(1, logs_.size());
     EXPECT_EQ(1, countLogs(TrackingLeaseMgr::TRACK_UPDATE_LEASE, 0, Lease::TYPE_V4));
 }
@@ -301,23 +284,20 @@ TEST_F(TrackingLeaseMgrTest, trackDeleteLease) {
                                          std::bind(&TrackingLeaseMgrTest::logCallback,
                                                    this,
                                                    TrackingLeaseMgr::TRACK_ADD_LEASE,
-                                                   SUBNET_ID_GLOBAL,
-                                                   ph::_1, ph::_2)));
+                                                   SUBNET_ID_GLOBAL, ph::_1)));
     EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_UPDATE_LEASE, "flq",
                                          SUBNET_ID_GLOBAL, Lease::TYPE_V4,
                                          std::bind(&TrackingLeaseMgrTest::logCallback,
                                                    this,
                                                    TrackingLeaseMgr::TRACK_UPDATE_LEASE,
-                                                   SUBNET_ID_GLOBAL,
-                                                   ph::_1, ph::_2)));
+                                                   SUBNET_ID_GLOBAL, ph::_1)));
     EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_DELETE_LEASE, "flq",
                                          SUBNET_ID_GLOBAL, Lease::TYPE_V4,
                                          std::bind(&TrackingLeaseMgrTest::logCallback,
                                                    this,
                                                    TrackingLeaseMgr::TRACK_DELETE_LEASE,
-                                                   SUBNET_ID_GLOBAL,
-                                                   ph::_1, ph::_2)));
-    EXPECT_NO_THROW(mgr.trackDeleteLease(initializeLease(1, "192.0.2.1"), false));
+                                                   SUBNET_ID_GLOBAL, ph::_1)));
+    EXPECT_NO_THROW(mgr.trackDeleteLease(initializeLease(1, "192.0.2.1")));
     EXPECT_EQ(1, logs_.size());
     EXPECT_EQ(1, countLogs(TrackingLeaseMgr::TRACK_DELETE_LEASE, SUBNET_ID_GLOBAL, Lease::TYPE_V4));
 }
@@ -333,58 +313,51 @@ TEST_F(TrackingLeaseMgrTest, unregisterCallbacksBySubnetID) {
                                          std::bind(&TrackingLeaseMgrTest::logCallback,
                                                    this,
                                                    TrackingLeaseMgr::TRACK_ADD_LEASE,
-                                                   SUBNET_ID_GLOBAL,
-                                                   ph::_1, ph::_2)));
+                                                   SUBNET_ID_GLOBAL, ph::_1)));
     EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_ADD_LEASE, "flq", 1,
                                          Lease::TYPE_V4,
                                          std::bind(&TrackingLeaseMgrTest::logCallback,
                                                    this,
                                                    TrackingLeaseMgr::TRACK_ADD_LEASE,
-                                                   1,
-                                                   ph::_1, ph::_2)));
+                                                   1, ph::_1)));
     EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_ADD_LEASE, "flq", 2,
                                          Lease::TYPE_V4,
                                          std::bind(&TrackingLeaseMgrTest::logCallback,
                                                    this,
                                                    TrackingLeaseMgr::TRACK_ADD_LEASE,
-                                                   2,
-                                                   ph::_1, ph::_2)));
+                                                   2, ph::_1)));
     EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_UPDATE_LEASE, "flq", 1,
                                          Lease::TYPE_V4,
                                          std::bind(&TrackingLeaseMgrTest::logCallback,
                                                    this,
                                                    TrackingLeaseMgr::TRACK_UPDATE_LEASE,
-                                                   1,
-                                                   ph::_1, ph::_2)));
+                                                   1, ph::_1)));
     EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_UPDATE_LEASE, "flq", 2,
                                          Lease::TYPE_V4,
                                          std::bind(&TrackingLeaseMgrTest::logCallback,
                                                    this,
                                                    TrackingLeaseMgr::TRACK_UPDATE_LEASE,
-                                                   2,
-                                                   ph::_1, ph::_2)));
+                                                   2, ph::_1)));
     EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_DELETE_LEASE, "flq", 1,
                                          Lease::TYPE_V4,
                                          std::bind(&TrackingLeaseMgrTest::logCallback,
                                                    this,
                                                    TrackingLeaseMgr::TRACK_DELETE_LEASE,
-                                                   1,
-                                                   ph::_1, ph::_2)));
+                                                   1, ph::_1)));
     EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_DELETE_LEASE, "flq", 2,
                                          Lease::TYPE_V4,
                                          std::bind(&TrackingLeaseMgrTest::logCallback,
                                                    this,
                                                    TrackingLeaseMgr::TRACK_DELETE_LEASE,
-                                                   2,
-                                                   ph::_1, ph::_2)));
+                                                   2, ph::_1)));
 
     // Unregister the callbacks for subnet id 1.
     EXPECT_NO_THROW(mgr.unregisterCallbacks(SubnetID(1), Lease::TYPE_V4));
 
     // Invoke the remaining callbacks for the subnet id 1.
-    EXPECT_NO_THROW(mgr.trackAddLease(initializeLease(1, "192.0.2.1"), false));
-    EXPECT_NO_THROW(mgr.trackUpdateLease(initializeLease(1, "192.0.2.1"), false));
-    EXPECT_NO_THROW(mgr.trackDeleteLease(initializeLease(1, "192.0.2.1"), false));
+    EXPECT_NO_THROW(mgr.trackAddLease(initializeLease(1, "192.0.2.1")));
+    EXPECT_NO_THROW(mgr.trackUpdateLease(initializeLease(1, "192.0.2.1")));
+    EXPECT_NO_THROW(mgr.trackDeleteLease(initializeLease(1, "192.0.2.1")));
 
     // It should only run the callback for the global subnet id that is still
     // registered.
@@ -395,7 +368,7 @@ TEST_F(TrackingLeaseMgrTest, unregisterCallbacksBySubnetID) {
     EXPECT_NO_THROW(mgr.unregisterCallbacks(SUBNET_ID_GLOBAL, Lease::TYPE_V4));
 
     // Make sure it is no longer invoked.
-    EXPECT_NO_THROW(mgr.trackAddLease(initializeLease(1, "192.0.2.1"), false));
+    EXPECT_NO_THROW(mgr.trackAddLease(initializeLease(1, "192.0.2.1")));
     EXPECT_EQ(1, logs_.size());
 
     // Unregistering it again should be no-op.
@@ -413,15 +386,13 @@ TEST_F(TrackingLeaseMgrTest, unregisterAllCallbacks) {
                                          std::bind(&TrackingLeaseMgrTest::logCallback,
                                                    this,
                                                    TrackingLeaseMgr::TRACK_ADD_LEASE,
-                                                   SUBNET_ID_GLOBAL,
-                                                   ph::_1, ph::_2)));
+                                                   SUBNET_ID_GLOBAL, ph::_1)));
     EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_UPDATE_LEASE, "flq",
                                          SUBNET_ID_GLOBAL, Lease::TYPE_V4,
                                          std::bind(&TrackingLeaseMgrTest::logCallback,
                                                    this,
                                                    TrackingLeaseMgr::TRACK_UPDATE_LEASE,
-                                                   SUBNET_ID_GLOBAL,
-                                                   ph::_1, ph::_2)));
+                                                   SUBNET_ID_GLOBAL, ph::_1)));
     // Make sure they have been registered.
     EXPECT_TRUE(mgr.hasCallbacks());
 
@@ -441,8 +412,7 @@ TEST_F(TrackingLeaseMgrTest, hasCallbacks) {
                                          std::bind(&TrackingLeaseMgrTest::logCallback,
                                                    this,
                                                    TrackingLeaseMgr::TRACK_ADD_LEASE,
-                                                   SUBNET_ID_GLOBAL,
-                                                   ph::_1, ph::_2)));
+                                                   SUBNET_ID_GLOBAL, ph::_1)));
     EXPECT_TRUE(mgr.hasCallbacks());
 }
 
index d9301246ef3a0d56ab77ca6103257017fc783a44..35c8192b474b3cc4fd5cbbcd378e3afc966d94c2 100644 (file)
@@ -41,18 +41,18 @@ TrackingLeaseMgr::isLocked(const LeasePtr& lease) {
 }
 
 void
-TrackingLeaseMgr::trackAddLease(const LeasePtr& lease, bool mt_safe) {
-    runCallbacks(TRACK_ADD_LEASE, lease, mt_safe);
+TrackingLeaseMgr::trackAddLease(const LeasePtr& lease) {
+    runCallbacks(TRACK_ADD_LEASE, lease);
 }
 
 void
-TrackingLeaseMgr::trackUpdateLease(const LeasePtr& lease, bool mt_safe) {
-    runCallbacks(TRACK_UPDATE_LEASE, lease, mt_safe);
+TrackingLeaseMgr::trackUpdateLease(const LeasePtr& lease) {
+    runCallbacks(TRACK_UPDATE_LEASE, lease);
 }
 
 void
-TrackingLeaseMgr::trackDeleteLease(const LeasePtr& lease, bool mt_safe) {
-    runCallbacks(TRACK_DELETE_LEASE, lease, mt_safe);
+TrackingLeaseMgr::trackDeleteLease(const LeasePtr& lease) {
+    runCallbacks(TRACK_DELETE_LEASE, lease);
 }
 
 void
@@ -124,15 +124,15 @@ TrackingLeaseMgr::callbackTypeToString(CallbackType type) {
 }
 
 void
-TrackingLeaseMgr::runCallbacks(TrackingLeaseMgr::CallbackType type, const LeasePtr& lease,
-                               bool mt_safe) {
-    runCallbacksForSubnetID(type, SUBNET_ID_GLOBAL, lease, mt_safe);
-    runCallbacksForSubnetID(type, lease->subnet_id_, lease, mt_safe);
+TrackingLeaseMgr::runCallbacks(TrackingLeaseMgr::CallbackType type,
+                               const LeasePtr& lease) {
+    runCallbacksForSubnetID(type, SUBNET_ID_GLOBAL, lease);
+    runCallbacksForSubnetID(type, lease->subnet_id_, lease);
 }
 
 void
 TrackingLeaseMgr::runCallbacksForSubnetID(CallbackType type, SubnetID subnet_id,
-                                          const LeasePtr& lease, bool mt_safe) {
+                                          const LeasePtr& lease) {
     // The first index filters by callback type and subnet_id.
     auto& idx = callbacks_->get<0>();
     auto cbs = idx.equal_range(boost::make_tuple(type, subnet_id, lease->getType()));
@@ -142,7 +142,7 @@ TrackingLeaseMgr::runCallbacksForSubnetID(CallbackType type, SubnetID subnet_id,
     for (auto it = cbs.first; it != cbs.second; ++it) {
         auto cb = *it;
         try {
-            cb.fn(lease, mt_safe);
+            cb.fn(lease);
         } catch (const std::exception& ex) {
             LOG_WARN(dhcpsrv_logger, DHCPSRV_LEASE_MGR_CALLBACK_EXCEPTION)
                 .arg(callbackTypeToString(type))
index 62928c5ac34f6e1fb2d2301aa9a860cf970fa9a8..fe21177102913a29757027cbe9d47aff05c7e325 100644 (file)
@@ -93,9 +93,8 @@ public:
     /// update or deletion.
     ///
     /// The first argument is a pointer to the lease for which the callback
-    /// is invoked. The second argument indicates whether or not the callback
-    /// is invoked in the thread-safe context.
-    typedef std::function<void(LeasePtr, bool)> CallbackFn;
+    /// is invoked.
+    typedef std::function<void(LeasePtr)> CallbackFn;
 
     /// @brief A structure representing a registered callback.
     ///
@@ -105,15 +104,19 @@ public:
     /// callback registered for the particular owner, subnet identifier
     /// and the lease type.
     typedef struct {
-        /// Callback type (i.e., lease add, update, delete).
+        /// @brief Callback type (i.e., lease add, update, delete).
         CallbackType type;
-        /// An entity owning callback registration (e.g., FLQ allocator).
+
+        /// @brief An entity owning callback registration (e.g., FLQ allocator).
         std::string owner;
+
         /// Subnet identifier associated with the callback.
         SubnetID subnet_id;
-        /// Lease types for which the callback should be invoked.
+
+        /// @brief Lease types for which the callback should be invoked.
         Lease::Type lease_type;
-        /// Callback function.
+
+        /// @brief Callback function.
         CallbackFn fn;
     } Callback;
 
@@ -197,9 +200,7 @@ protected:
     /// The callbacks execution order is not guaranteed.
     ///
     /// @param lease new lease instance.
-    /// @param mt_safe a boolean flag indicating whether the callbacks are
-    /// invoked in the MT-safe context.
-    void trackAddLease(const LeasePtr& lease, bool mt_safe);
+    void trackAddLease(const LeasePtr& lease);
 
     /// @brief Invokes the callbacks when a lease is updated.
     ///
@@ -209,9 +210,7 @@ protected:
     /// The callbacks execution order is not guaranteed.
     ///
     /// @param lease updated lease instance.
-    /// @param mt_safe a boolean flag indicating whether the callbacks are
-    /// invoked in the MT-safe context.
-    void trackUpdateLease(const LeasePtr& lease, bool mt_safe);
+    void trackUpdateLease(const LeasePtr& lease);
 
     /// @brief Invokes the callbacks when a lease is deleted.
     ///
@@ -221,9 +220,7 @@ protected:
     /// The callbacks execution order is not guaranteed.
     ///
     /// @param lease deleted lease instance.
-    /// @param mt_safe a boolean flag indicating whether the callbacks are
-    /// invoked in the MT-safe context.
-    void trackDeleteLease(const LeasePtr& lease, bool mt_safe);
+    void trackDeleteLease(const LeasePtr& lease);
 
 public:
 
@@ -283,9 +280,7 @@ protected:
     ///
     /// @param type callback type.
     /// @param lease lease instance for which the callbacks are invoked.
-    /// @param mt_safe a boolean flag indicating whether the callbacks are
-    /// invoked in the MT-safe context.
-    void runCallbacks(CallbackType type, const LeasePtr& lease, bool mt_safe);
+    void runCallbacks(CallbackType type, const LeasePtr& lease);
 
     /// @brief Runs registered callbacks of the particular type for a subnet id.
     ///
@@ -294,10 +289,8 @@ protected:
     /// @param type callback type.
     /// @param subnet_id subnet identifier for which the callbacks are invoked.
     /// @param lease lease instance for which the callbacks are invoked.
-    /// @param mt_safe a boolean flag indicating whether the callbacks are
-    /// invoked in the MT-safe context.
     void runCallbacksForSubnetID(CallbackType type, SubnetID subnet_id,
-                                 const LeasePtr& lease, bool mt_safe);
+                                 const LeasePtr& lease);
 
     /// @brief The multi-index container holding registered callbacks.
     CallbackContainerPtr callbacks_;