diff options
author | Sunitha Harish <sunithaharish04@gmail.com> | 2022-08-08 10:08:39 +0300 |
---|---|---|
committer | Sunitha Harish <sunithaharish04@gmail.com> | 2022-09-06 05:01:09 +0300 |
commit | 3e7ab70817a6e49684c7c01ec0f2d67630f36559 (patch) | |
tree | 709b24e83a341e86852884e9d280ce463bb86691 /include/ibm | |
parent | f8a4347ec8afa33c927f652ab0a5ed9ddbb37b98 (diff) | |
download | bmcweb-3e7ab70817a6e49684c7c01ec0f2d67630f36559.tar.xz |
IBM Mgmt console lock algorithm improvement
This commit optimizes the release lock code and adds some traces to give
more data for lock conflict scenarios
Tested by:
1. With dual client connected, verified the conflicts are returned
2. Tested releaseLock usecase
Signed-off-by: Sunitha Harish <sunithaharish04@gmail.com>
Change-Id: I3cf99aaa5cc7c2967ae8dbc9c76c9f7378ecebdd
Diffstat (limited to 'include/ibm')
-rw-r--r-- | include/ibm/locks.hpp | 43 | ||||
-rw-r--r-- | include/ibm/management_console_rest.hpp | 6 |
2 files changed, 21 insertions, 28 deletions
diff --git a/include/ibm/locks.hpp b/include/ibm/locks.hpp index 5220a5da14..7cd803763e 100644 --- a/include/ibm/locks.hpp +++ b/include/ibm/locks.hpp @@ -220,23 +220,20 @@ inline RcGetLockList Lock::getLockList(const ListOfSessionIds& listSessionId) inline RcReleaseLockApi Lock::releaseLock(const ListOfTransactionIds& p, const SessionFlags& ids) { - bool status = validateRids(p); if (!status) { // Validation of rids failed - BMCWEB_LOG_DEBUG << "Not a Valid request id"; + BMCWEB_LOG_ERROR << "releaseLock: Contains invalid request id"; return std::make_pair(false, status); } // Validation passed, check if all the locks are owned by the // requesting HMC auto status2 = isItMyLock(p, ids); - if (status2.first) + if (!status2.first) { - // The current hmc owns all the locks, so we can release - // them - releaseLock(p); + return std::make_pair(false, status2); } return std::make_pair(true, status2); } @@ -276,25 +273,6 @@ inline RcAcquireLock Lock::acquireLock(const LockRequests& lockRequestStructure) return std::make_pair(false, conflict); } -inline void Lock::releaseLock(const ListOfTransactionIds& refRids) -{ - for (const auto& id : refRids) - { - if (lockTable.erase(id) != 0U) - { - BMCWEB_LOG_DEBUG << "Removing the locks with transaction ID : " - << id; - } - - else - { - BMCWEB_LOG_DEBUG << "Removing the locks from the lock table " - "failed, transaction ID: " - << id; - } - } -} - inline void Lock::releaseLock(const std::string& sessionId) { if (!lockTable.empty()) @@ -339,6 +317,18 @@ inline RcRelaseLock Lock::isItMyLock(const ListOfTransactionIds& refRids, { // It is owned by the currently request hmc BMCWEB_LOG_DEBUG << "Lock is owned by the current hmc"; + // remove the lock + if (lockTable.erase(id) != 0U) + { + BMCWEB_LOG_DEBUG << "Removing the locks with transaction ID : " + << id; + } + else + { + BMCWEB_LOG_ERROR << "Removing the locks from the lock table " + "failed, transaction ID: " + << id; + } } else { @@ -362,7 +352,8 @@ inline bool Lock::validateRids(const ListOfTransactionIds& refRids) } else { - BMCWEB_LOG_DEBUG << "At least 1 inValid Request id"; + BMCWEB_LOG_ERROR << "validateRids: At least 1 inValid Request id: " + << id; return false; } } diff --git a/include/ibm/management_console_rest.hpp b/include/ibm/management_console_rest.hpp index e51f64a37a..0a8b146715 100644 --- a/include/ibm/management_console_rest.hpp +++ b/include/ibm/management_console_rest.hpp @@ -488,7 +488,7 @@ inline void } if (validityStatus.first && (validityStatus.second == 1)) { - BMCWEB_LOG_DEBUG << "There is a conflict within itself"; + BMCWEB_LOG_ERROR << "There is a conflict within itself"; asyncResp->res.result(boost::beast::http::status::conflict); return; } @@ -529,7 +529,7 @@ inline void } returnJson["SegmentFlags"] = myarray; - + BMCWEB_LOG_ERROR << "Conflicting lock record: " << returnJson; asyncResp->res.jsonValue["Record"] = returnJson; return; } @@ -563,6 +563,7 @@ inline void if (!varReleaselock.first) { // validation Failed + BMCWEB_LOG_ERROR << "handleReleaseLockAPI: validation failed"; asyncResp->res.result(boost::beast::http::status::bad_request); return; } @@ -597,6 +598,7 @@ inline void } returnJson["SegmentFlags"] = myArray; + BMCWEB_LOG_DEBUG << "handleReleaseLockAPI: lockrecord: " << returnJson; asyncResp->res.jsonValue["Record"] = returnJson; } |