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/locks.hpp | |
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/locks.hpp')
-rw-r--r-- | include/ibm/locks.hpp | 43 |
1 files changed, 17 insertions, 26 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; } } |