2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-31 14:05:33 +00:00

[#1073] addressed review

This commit is contained in:
Razvan Becheriu
2020-01-27 15:55:03 +02:00
parent 3061507cb9
commit 430cefea69
5 changed files with 38 additions and 1 deletions

View File

@@ -1727,7 +1727,9 @@ MySqlLeaseMgr::MySqlLeaseContextAlloc::MySqlLeaseContextAlloc(
const MySqlLeaseMgr& mgr) : ctx_(), mgr_(mgr) {
if (MultiThreadingMgr::instance().getMode()) {
// multi-threaded
{
// we need to protect the whole pool_ operation, hence extra scope {}
lock_guard<mutex> lock(mgr_.pool_->mutex_);
if (!mgr_.pool_->pool_.empty()) {
ctx_ = mgr_.pool_->pool_.back();
@@ -1738,6 +1740,7 @@ MySqlLeaseMgr::MySqlLeaseContextAlloc::MySqlLeaseContextAlloc(
ctx_ = mgr_.createContext();
}
} else {
// single-threaded
if (mgr_.pool_->pool_.empty()) {
isc_throw(Unexpected, "No available MySQL lease context?!");
}
@@ -1747,9 +1750,11 @@ MySqlLeaseMgr::MySqlLeaseContextAlloc::MySqlLeaseContextAlloc(
MySqlLeaseMgr::MySqlLeaseContextAlloc::~MySqlLeaseContextAlloc() {
if (MultiThreadingMgr::instance().getMode()) {
// multi-threaded
lock_guard<mutex> lock(mgr_.pool_->mutex_);
mgr_.pool_->pool_.push_back(ctx_);
}
// If running in single-threaded mode, there's nothing to do here.
}
// MySqlLeaseMgr Constructor and Destructor