+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
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>
}
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);
}
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);
}
}
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);
}
/// 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.
///
/// 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.
///
/// 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.
///
// Run installed callbacks.
if (hasCallbacks()) {
- trackAddLease(lease, true);
+ trackAddLease(lease);
}
return (true);
// Run installed callbacks.
if (hasCallbacks()) {
- trackAddLease(lease, true);
+ trackAddLease(lease);
}
return (true);
// Run installed callbacks.
if (hasCallbacks()) {
- trackUpdateLease(lease, true);
+ trackUpdateLease(lease);
}
}
// Run installed callbacks.
if (hasCallbacks()) {
- trackUpdateLease(lease, true);
+ trackUpdateLease(lease);
}
}
// Run installed callbacks.
if (hasCallbacks()) {
- trackDeleteLease(lease, true);
+ trackDeleteLease(lease);
}
return (true);
// Run installed callbacks.
if (hasCallbacks()) {
- trackDeleteLease(lease, true);
+ trackDeleteLease(lease);
}
return (true);
// Run installed callbacks.
if (hasCallbacks()) {
- trackAddLease(lease, false);
+ trackAddLease(lease);
}
return (result);
// Run installed callbacks.
if (hasCallbacks()) {
- trackAddLease(lease, false);
+ trackAddLease(lease);
}
return (result);
// Run installed callbacks.
if (hasCallbacks()) {
- trackUpdateLease(lease, false);
+ trackUpdateLease(lease);
}
}
// Run installed callbacks.
if (hasCallbacks()) {
- trackUpdateLease(lease, false);
+ trackUpdateLease(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);
}
// Check success case first as it is the most likely outcome.
if (affected_rows == 1) {
if (hasCallbacks()) {
- trackDeleteLease(lease, false);
+ trackDeleteLease(lease);
}
return (true);
}
// Run installed callbacks.
if (hasCallbacks()) {
- trackAddLease(lease, false);
+ trackAddLease(lease);
}
return (result);
// Run installed callbacks.
if (hasCallbacks()) {
- trackAddLease(lease, false);
+ trackAddLease(lease);
}
return (result);
// Run installed callbacks.
if (hasCallbacks()) {
- trackUpdateLease(lease, false);
+ trackUpdateLease(lease);
}
}
// Run installed callbacks.
if (hasCallbacks()) {
- trackUpdateLease(lease, false);
+ trackUpdateLease(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);
}
// Check success case first as it is the most likely outcome.
if (affected_rows == 1) {
if (hasCallbacks()) {
- trackDeleteLease(lease, false);
+ trackDeleteLease(lease);
}
return (true);
}
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
}
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));
} 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));
} 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));
} 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,
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));
} 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));
} 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));
} 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));
} 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));
} 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));
} 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));
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));
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));
TrackingLeaseMgr::CallbackType type;
SubnetID subnet_id;
LeasePtr lease;
- bool mt_safe;
bool locked;
} Log;
/// @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.
///
///
/// @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.
/// 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
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
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
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
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
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
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
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
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
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
/// @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
/// @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
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));
}
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",
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.
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,
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,
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.
std::bind(&TrackingLeaseMgrTest::logCallback,
this,
TrackingLeaseMgr::TRACK_ADD_LEASE,
- 5,
- ph::_1, ph::_2)));
+ 5, ph::_1)));
}
/// Test invoking the registered lease add callbacks.
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));
}
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));
}
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));
}
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.
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.
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());
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());
}
}
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
}
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()));
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))
/// 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.
///
/// 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;
/// 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.
///
/// 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.
///
/// 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:
///
/// @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.
///
/// @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_;