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
diff --git a/include/ibm/locks.hpp b/include/ibm/locks.hpp
index 5220a5d..7cd8037 100644
--- a/include/ibm/locks.hpp
+++ b/include/ibm/locks.hpp
@@ -220,23 +220,20 @@
 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 @@
     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 @@
         {
             // 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 @@
         }
         else
         {
-            BMCWEB_LOG_DEBUG << "At least 1 inValid Request id";
+            BMCWEB_LOG_ERROR << "validateRids: At least 1 inValid Request id: "
+                             << id;
             return false;
         }
     }