manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 1 | #pragma once |
| 2 | |
manojkiraneda | 4eaf2ee | 2019-12-13 17:10:41 +0530 | [diff] [blame] | 3 | #include <logging.h> |
| 4 | |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 5 | #include <boost/algorithm/string.hpp> |
| 6 | #include <boost/container/flat_map.hpp> |
Manojkiran Eda | 55fd1a9 | 2020-04-30 19:06:48 +0530 | [diff] [blame] | 7 | #include <boost/endian/conversion.hpp> |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 8 | #include <nlohmann/json.hpp> |
| 9 | |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 10 | #include <filesystem> |
Sunitha Harish | 8a3bb71 | 2019-12-13 03:48:09 -0600 | [diff] [blame] | 11 | #include <fstream> |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 12 | |
| 13 | namespace crow |
| 14 | { |
| 15 | namespace ibm_mc_lock |
| 16 | { |
| 17 | |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 18 | using SType = std::string; |
| 19 | |
| 20 | /*---------------------------------------- |
| 21 | |Segment flags : LockFlag | SegmentLength| |
| 22 | ------------------------------------------*/ |
| 23 | |
| 24 | using SegmentFlags = std::vector<std::pair<SType, uint32_t>>; |
| 25 | |
| 26 | // Lockrequest = session-id | hmc-id | locktype | resourceid | segmentinfo |
| 27 | using LockRequest = std::tuple<SType, SType, SType, uint64_t, SegmentFlags>; |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 28 | using LockRequests = std::vector<LockRequest>; |
| 29 | using Rc = |
| 30 | std::pair<bool, std::variant<uint32_t, std::pair<uint32_t, LockRequest>>>; |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 31 | using RcRelaseLock = std::pair<bool, std::pair<uint32_t, LockRequest>>; |
manojkiraneda | 402b571 | 2019-12-13 17:07:09 +0530 | [diff] [blame] | 32 | using RcGetLockList = |
| 33 | std::variant<std::string, std::vector<std::pair<uint32_t, LockRequests>>>; |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 34 | using ListOfTransactionIds = std::vector<uint32_t>; |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 35 | using RcAcquireLock = std::pair<bool, std::variant<Rc, std::pair<bool, int>>>; |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 36 | using RcReleaseLockApi = std::pair<bool, std::variant<bool, RcRelaseLock>>; |
| 37 | using SessionFlags = std::pair<SType, SType>; |
manojkiraneda | 402b571 | 2019-12-13 17:07:09 +0530 | [diff] [blame] | 38 | using ListOfSessionIds = std::vector<std::string>; |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 39 | static constexpr const char* fileName = |
Sunitha Harish | 8a3bb71 | 2019-12-13 03:48:09 -0600 | [diff] [blame] | 40 | "/var/lib/obmc/bmc-console-mgmt/locks/ibm_mc_persistent_lock_data.json"; |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 41 | |
| 42 | class Lock |
| 43 | { |
| 44 | uint32_t transactionId; |
| 45 | boost::container::flat_map<uint32_t, LockRequests> lockTable; |
| 46 | |
| 47 | /* |
Sunitha Harish | 8a3bb71 | 2019-12-13 03:48:09 -0600 | [diff] [blame] | 48 | * This API implements the logic to persist the locks that are contained in |
| 49 | * the lock table into a json file. |
| 50 | */ |
| 51 | void saveLocks(); |
| 52 | |
| 53 | /* |
| 54 | * This API implements the logic to load the locks that are present in the |
| 55 | * json file into the lock table. |
| 56 | */ |
| 57 | void loadLocks(); |
| 58 | |
manojkiraneda | 4eaf2ee | 2019-12-13 17:10:41 +0530 | [diff] [blame] | 59 | bool createPersistentLockFilePath(); |
| 60 | |
| 61 | protected: |
| 62 | /* |
| 63 | * This function implements the logic for validating an incoming |
| 64 | * lock request/requests. |
| 65 | * |
| 66 | * Returns : True (if Valid) |
| 67 | * Returns : False (if not a Valid lock request) |
| 68 | */ |
| 69 | |
Ed Tanous | b5a7693 | 2020-09-29 16:16:58 -0700 | [diff] [blame^] | 70 | virtual bool isValidLockRequest(const LockRequest&); |
manojkiraneda | 4eaf2ee | 2019-12-13 17:10:41 +0530 | [diff] [blame] | 71 | |
| 72 | /* |
| 73 | * This function implements the logic of checking if the incoming |
| 74 | * multi-lock request is not having conflicting requirements. |
| 75 | * |
| 76 | * Returns : True (if conflicting) |
| 77 | * Returns : False (if not conflicting) |
| 78 | */ |
| 79 | |
Ed Tanous | b5a7693 | 2020-09-29 16:16:58 -0700 | [diff] [blame^] | 80 | virtual bool isConflictRequest(const LockRequests&); |
manojkiraneda | 4eaf2ee | 2019-12-13 17:10:41 +0530 | [diff] [blame] | 81 | /* |
| 82 | * Implements the core algorithm to find the conflicting |
| 83 | * lock requests. |
| 84 | * |
| 85 | * This functions takes two lock requests and check if both |
| 86 | * are conflicting to each other. |
| 87 | * |
| 88 | * Returns : True (if conflicting) |
| 89 | * Returns : False (if not conflicting) |
| 90 | */ |
Ed Tanous | b5a7693 | 2020-09-29 16:16:58 -0700 | [diff] [blame^] | 91 | virtual bool isConflictRecord(const LockRequest&, const LockRequest&); |
manojkiraneda | 4eaf2ee | 2019-12-13 17:10:41 +0530 | [diff] [blame] | 92 | |
| 93 | /* |
| 94 | * This function implements the logic of checking the conflicting |
| 95 | * locks from a incoming single/multi lock requests with the already |
| 96 | * existing lock request in the lock table. |
| 97 | * |
| 98 | */ |
| 99 | |
Ed Tanous | b5a7693 | 2020-09-29 16:16:58 -0700 | [diff] [blame^] | 100 | virtual Rc isConflictWithTable(const LockRequests&); |
manojkiraneda | 4eaf2ee | 2019-12-13 17:10:41 +0530 | [diff] [blame] | 101 | /* |
| 102 | * This function implements the logic of checking the ownership of the |
| 103 | * lock from the releaselock request. |
| 104 | * |
| 105 | * Returns : True (if the requesting HMC & Session owns the lock(s)) |
| 106 | * Returns : False (if the request HMC or Session does not own the lock(s)) |
| 107 | */ |
| 108 | |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 109 | virtual RcRelaseLock isItMyLock(const ListOfTransactionIds&, |
| 110 | const SessionFlags&); |
manojkiraneda | 4eaf2ee | 2019-12-13 17:10:41 +0530 | [diff] [blame] | 111 | |
| 112 | /* |
| 113 | * This function validates the the list of transactionID's and returns false |
| 114 | * if the transaction ID is not valid & not present in the lock table |
| 115 | */ |
| 116 | |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 117 | virtual bool validateRids(const ListOfTransactionIds&); |
manojkiraneda | 4eaf2ee | 2019-12-13 17:10:41 +0530 | [diff] [blame] | 118 | |
| 119 | /* |
| 120 | * This function releases the locks that are already obtained by the |
| 121 | * requesting Management console. |
| 122 | */ |
| 123 | |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 124 | void releaseLock(const ListOfTransactionIds&); |
manojkiraneda | 4eaf2ee | 2019-12-13 17:10:41 +0530 | [diff] [blame] | 125 | |
| 126 | Lock() |
| 127 | { |
| 128 | loadLocks(); |
| 129 | transactionId = lockTable.empty() ? 0 : prev(lockTable.end())->first; |
| 130 | } |
| 131 | |
Sunitha Harish | 8a3bb71 | 2019-12-13 03:48:09 -0600 | [diff] [blame] | 132 | /* |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 133 | * This function implements the algorithm for checking the respective |
| 134 | * bytes of the resource id based on the lock management algorithm. |
| 135 | */ |
| 136 | |
| 137 | bool checkByte(uint64_t, uint64_t, uint32_t); |
| 138 | |
| 139 | /* |
| 140 | * This functions implements a counter that generates a unique 32 bit |
| 141 | * number for every successful transaction. This number will be used by |
| 142 | * the Management Console for debug. |
| 143 | */ |
manojkiraneda | 4eaf2ee | 2019-12-13 17:10:41 +0530 | [diff] [blame] | 144 | virtual uint32_t generateTransactionId(); |
Sunitha Harish | 8a3bb71 | 2019-12-13 03:48:09 -0600 | [diff] [blame] | 145 | |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 146 | public: |
| 147 | /* |
| 148 | * This function implements the logic for acquiring a lock on a |
Manojkiran Eda | 5bb0ece | 2020-01-20 20:22:36 +0530 | [diff] [blame] | 149 | * resource if the incoming request is legitimate without any |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 150 | * conflicting requirements & without any conflicting requirement |
Gunnar Mills | caa3ce3 | 2020-07-08 14:46:53 -0500 | [diff] [blame] | 151 | * with the existing locks in the lock table. |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 152 | * |
| 153 | */ |
| 154 | |
Ed Tanous | b5a7693 | 2020-09-29 16:16:58 -0700 | [diff] [blame^] | 155 | RcAcquireLock acquireLock(const LockRequests&); |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 156 | |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 157 | /* |
| 158 | * This function implements the logic for releasing the lock that are |
| 159 | * owned by a management console session. |
| 160 | * |
| 161 | * The locks can be released by two ways |
| 162 | * - Using list of transaction ID's |
| 163 | * - Using a Session ID |
| 164 | * |
| 165 | * Client can choose either of the ways by using `Type` JSON key. |
| 166 | * |
| 167 | */ |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 168 | RcReleaseLockApi releaseLock(const ListOfTransactionIds&, |
| 169 | const SessionFlags&); |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 170 | |
manojkiraneda | 402b571 | 2019-12-13 17:07:09 +0530 | [diff] [blame] | 171 | /* |
| 172 | * This function implements the logic for getting the list of locks obtained |
| 173 | * by a particular management console. |
| 174 | */ |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 175 | RcGetLockList getLockList(const ListOfSessionIds&); |
manojkiraneda | 402b571 | 2019-12-13 17:07:09 +0530 | [diff] [blame] | 176 | |
Ratan Gupta | 07386c6 | 2019-12-14 14:06:09 +0530 | [diff] [blame] | 177 | /* |
| 178 | * This function is releases all the locks obtained by a particular |
| 179 | * session. |
| 180 | */ |
| 181 | |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 182 | void releaseLock(const std::string&); |
Ratan Gupta | 07386c6 | 2019-12-14 14:06:09 +0530 | [diff] [blame] | 183 | |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 184 | static Lock& getInstance() |
Ratan Gupta | 07386c6 | 2019-12-14 14:06:09 +0530 | [diff] [blame] | 185 | { |
| 186 | static Lock lockObject; |
| 187 | return lockObject; |
| 188 | } |
manojkiraneda | 4eaf2ee | 2019-12-13 17:10:41 +0530 | [diff] [blame] | 189 | |
Ed Tanous | 4e08751 | 2020-09-28 18:41:25 -0700 | [diff] [blame] | 190 | virtual ~Lock() = default; |
Ratan Gupta | 07386c6 | 2019-12-14 14:06:09 +0530 | [diff] [blame] | 191 | }; |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 192 | |
Ratan Gupta | 07386c6 | 2019-12-14 14:06:09 +0530 | [diff] [blame] | 193 | inline bool Lock::createPersistentLockFilePath() |
Sunitha Harish | 8a3bb71 | 2019-12-13 03:48:09 -0600 | [diff] [blame] | 194 | { |
| 195 | // The path /var/lib/obmc will be created by initrdscripts |
| 196 | // Create the directories for the persistent lock file |
| 197 | std::error_code ec; |
| 198 | if (!std::filesystem::is_directory("/var/lib/obmc/bmc-console-mgmt", ec)) |
| 199 | { |
| 200 | std::filesystem::create_directory("/var/lib/obmc/bmc-console-mgmt", ec); |
| 201 | } |
| 202 | if (ec) |
| 203 | { |
| 204 | BMCWEB_LOG_DEBUG |
| 205 | << "Failed to prepare bmc-console-mgmt directory. ec : " << ec; |
| 206 | return false; |
| 207 | } |
| 208 | |
| 209 | if (!std::filesystem::is_directory("/var/lib/obmc/bmc-console-mgmt/locks", |
| 210 | ec)) |
| 211 | { |
| 212 | std::filesystem::create_directory( |
| 213 | "/var/lib/obmc/bmc-console-mgmt/locks", ec); |
| 214 | } |
| 215 | if (ec) |
| 216 | { |
| 217 | BMCWEB_LOG_DEBUG |
| 218 | << "Failed to prepare persistent lock file directory. ec : " << ec; |
| 219 | return false; |
| 220 | } |
| 221 | return true; |
| 222 | } |
| 223 | |
Ratan Gupta | 07386c6 | 2019-12-14 14:06:09 +0530 | [diff] [blame] | 224 | inline void Lock::loadLocks() |
Sunitha Harish | 8a3bb71 | 2019-12-13 03:48:09 -0600 | [diff] [blame] | 225 | { |
| 226 | std::ifstream persistentFile(fileName); |
| 227 | if (persistentFile.is_open()) |
| 228 | { |
| 229 | auto data = nlohmann::json::parse(persistentFile, nullptr, false); |
| 230 | if (data.is_discarded()) |
| 231 | { |
| 232 | BMCWEB_LOG_ERROR << "Error parsing persistent data in json file."; |
| 233 | return; |
| 234 | } |
| 235 | BMCWEB_LOG_DEBUG << "The persistent lock data is available"; |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 236 | for (const auto& item : data.items()) |
Sunitha Harish | 8a3bb71 | 2019-12-13 03:48:09 -0600 | [diff] [blame] | 237 | { |
| 238 | BMCWEB_LOG_DEBUG << item.key(); |
| 239 | BMCWEB_LOG_DEBUG << item.value(); |
| 240 | LockRequests locks = item.value(); |
Ratan Gupta | 07386c6 | 2019-12-14 14:06:09 +0530 | [diff] [blame] | 241 | lockTable.emplace(std::pair<uint32_t, LockRequests>( |
Sunitha Harish | 8a3bb71 | 2019-12-13 03:48:09 -0600 | [diff] [blame] | 242 | std::stoul(item.key()), locks)); |
| 243 | BMCWEB_LOG_DEBUG << "The persistent lock data loaded"; |
| 244 | } |
| 245 | } |
| 246 | } |
| 247 | |
Ratan Gupta | 07386c6 | 2019-12-14 14:06:09 +0530 | [diff] [blame] | 248 | inline void Lock::saveLocks() |
Sunitha Harish | 8a3bb71 | 2019-12-13 03:48:09 -0600 | [diff] [blame] | 249 | { |
| 250 | std::error_code ec; |
| 251 | if (!std::filesystem::is_directory("/var/lib/obmc/bmc-console-mgmt/locks", |
| 252 | ec)) |
| 253 | { |
| 254 | if (!createPersistentLockFilePath()) |
| 255 | { |
| 256 | BMCWEB_LOG_DEBUG << "Failed to create lock persistent path"; |
| 257 | return; |
| 258 | } |
| 259 | } |
| 260 | std::ofstream persistentFile(fileName); |
| 261 | // set the permission of the file to 640 |
Ed Tanous | b5a7693 | 2020-09-29 16:16:58 -0700 | [diff] [blame^] | 262 | std::filesystem::perms permission = std::filesystem::perms::owner_read | |
| 263 | std::filesystem::perms::owner_write | |
| 264 | std::filesystem::perms::group_read; |
| 265 | std::filesystem::permissions(fileName, permission); |
Sunitha Harish | 8a3bb71 | 2019-12-13 03:48:09 -0600 | [diff] [blame] | 266 | nlohmann::json data; |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 267 | for (const auto& it : lockTable) |
Sunitha Harish | 8a3bb71 | 2019-12-13 03:48:09 -0600 | [diff] [blame] | 268 | { |
| 269 | data[std::to_string(it.first)] = it.second; |
| 270 | } |
| 271 | BMCWEB_LOG_DEBUG << "data is " << data; |
| 272 | persistentFile << data; |
| 273 | } |
| 274 | |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 275 | inline RcGetLockList Lock::getLockList(const ListOfSessionIds& listSessionId) |
manojkiraneda | 402b571 | 2019-12-13 17:07:09 +0530 | [diff] [blame] | 276 | { |
| 277 | |
| 278 | std::vector<std::pair<uint32_t, LockRequests>> lockList; |
| 279 | |
| 280 | if (!lockTable.empty()) |
| 281 | { |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 282 | for (const auto& i : listSessionId) |
manojkiraneda | 402b571 | 2019-12-13 17:07:09 +0530 | [diff] [blame] | 283 | { |
| 284 | auto it = lockTable.begin(); |
| 285 | while (it != lockTable.end()) |
| 286 | { |
| 287 | // Check if session id of this entry matches with session id |
| 288 | // given |
| 289 | if (std::get<0>(it->second[0]) == i) |
| 290 | { |
| 291 | BMCWEB_LOG_DEBUG << "Session id is found in the locktable"; |
| 292 | |
| 293 | // Push the whole lock record into a vector for returning |
| 294 | // the json |
Ed Tanous | 4e08751 | 2020-09-28 18:41:25 -0700 | [diff] [blame] | 295 | lockList.emplace_back(it->first, it->second); |
manojkiraneda | 402b571 | 2019-12-13 17:07:09 +0530 | [diff] [blame] | 296 | } |
| 297 | // Go to next entry in map |
| 298 | it++; |
| 299 | } |
| 300 | } |
| 301 | } |
| 302 | // we may have found at least one entry with the given session id |
| 303 | // return the json list of lock records pertaining to the given |
| 304 | // session id, or send an empty list if lock table is empty |
Ed Tanous | 02379d3 | 2020-09-15 21:15:44 -0700 | [diff] [blame] | 305 | return {lockList}; |
manojkiraneda | 402b571 | 2019-12-13 17:07:09 +0530 | [diff] [blame] | 306 | } |
| 307 | |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 308 | inline RcReleaseLockApi Lock::releaseLock(const ListOfTransactionIds& p, |
| 309 | const SessionFlags& ids) |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 310 | { |
| 311 | |
| 312 | bool status = validateRids(p); |
| 313 | |
| 314 | if (!status) |
| 315 | { |
| 316 | // Validation of rids failed |
| 317 | BMCWEB_LOG_DEBUG << "Not a Valid request id"; |
| 318 | return std::make_pair(false, status); |
| 319 | } |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 320 | // Validation passed, check if all the locks are owned by the |
| 321 | // requesting HMC |
| 322 | auto status2 = isItMyLock(p, ids); |
| 323 | if (status2.first) |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 324 | { |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 325 | // The current hmc owns all the locks, so we can release |
| 326 | // them |
| 327 | releaseLock(p); |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 328 | } |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 329 | return std::make_pair(true, status); |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 330 | } |
| 331 | |
Ed Tanous | b5a7693 | 2020-09-29 16:16:58 -0700 | [diff] [blame^] | 332 | inline RcAcquireLock Lock::acquireLock(const LockRequests& lockRequestStructure) |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 333 | { |
| 334 | |
| 335 | // validate the lock request |
| 336 | |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 337 | for (auto& lockRecord : lockRequestStructure) |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 338 | { |
| 339 | bool status = isValidLockRequest(lockRecord); |
| 340 | if (!status) |
| 341 | { |
| 342 | BMCWEB_LOG_DEBUG << "Not a Valid record"; |
| 343 | BMCWEB_LOG_DEBUG << "Bad json in request"; |
| 344 | return std::make_pair(true, std::make_pair(status, 0)); |
| 345 | } |
| 346 | } |
| 347 | // check for conflict record |
| 348 | |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 349 | const LockRequests& multiRequest = lockRequestStructure; |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 350 | bool status = isConflictRequest(multiRequest); |
| 351 | |
| 352 | if (status) |
| 353 | { |
| 354 | BMCWEB_LOG_DEBUG << "There is a conflict within itself"; |
| 355 | return std::make_pair(true, std::make_pair(status, 1)); |
| 356 | } |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 357 | BMCWEB_LOG_DEBUG << "The request is not conflicting within itself"; |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 358 | |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 359 | // Need to check for conflict with the locktable entries. |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 360 | |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 361 | auto conflict = isConflictWithTable(multiRequest); |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 362 | |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 363 | BMCWEB_LOG_DEBUG << "Done with checking conflict with the locktable"; |
| 364 | return std::make_pair(false, conflict); |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 365 | } |
| 366 | |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 367 | inline void Lock::releaseLock(const ListOfTransactionIds& refRids) |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 368 | { |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 369 | for (const auto& id : refRids) |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 370 | { |
| 371 | if (lockTable.erase(id)) |
| 372 | { |
| 373 | BMCWEB_LOG_DEBUG << "Removing the locks with transaction ID : " |
| 374 | << id; |
| 375 | } |
| 376 | |
| 377 | else |
| 378 | { |
| 379 | BMCWEB_LOG_DEBUG << "Removing the locks from the lock table " |
Gunnar Mills | caa3ce3 | 2020-07-08 14:46:53 -0500 | [diff] [blame] | 380 | "failed, transaction ID: " |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 381 | << id; |
| 382 | } |
| 383 | } |
Sunitha Harish | 8a3bb71 | 2019-12-13 03:48:09 -0600 | [diff] [blame] | 384 | |
| 385 | saveLocks(); |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 386 | } |
| 387 | |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 388 | inline void Lock::releaseLock(const std::string& sessionId) |
Ratan Gupta | 07386c6 | 2019-12-14 14:06:09 +0530 | [diff] [blame] | 389 | { |
| 390 | bool isErased = false; |
| 391 | if (!lockTable.empty()) |
| 392 | { |
| 393 | auto it = lockTable.begin(); |
| 394 | while (it != lockTable.end()) |
| 395 | { |
| 396 | if (it->second.size() != 0) |
| 397 | { |
| 398 | // Check if session id of this entry matches with session id |
| 399 | // given |
| 400 | if (std::get<0>(it->second[0]) == sessionId) |
| 401 | { |
| 402 | BMCWEB_LOG_DEBUG << "Remove the lock from the locktable " |
| 403 | "having sessionID=" |
| 404 | << sessionId; |
| 405 | BMCWEB_LOG_DEBUG << "TransactionID =" << it->first; |
| 406 | it = lockTable.erase(it); |
| 407 | isErased = true; |
| 408 | } |
| 409 | else |
| 410 | { |
| 411 | it++; |
| 412 | } |
| 413 | } |
| 414 | } |
| 415 | if (isErased) |
| 416 | { |
| 417 | // save the lock in the persistent file |
| 418 | saveLocks(); |
| 419 | } |
| 420 | } |
| 421 | } |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 422 | inline RcRelaseLock Lock::isItMyLock(const ListOfTransactionIds& refRids, |
| 423 | const SessionFlags& ids) |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 424 | { |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 425 | for (const auto& id : refRids) |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 426 | { |
| 427 | // Just need to compare the client id of the first lock records in the |
| 428 | // complete lock row(in the map), because the rest of the lock records |
| 429 | // would have the same client id |
| 430 | |
| 431 | std::string expectedClientId = std::get<1>(lockTable[id][0]); |
| 432 | std::string expectedSessionId = std::get<0>(lockTable[id][0]); |
| 433 | |
| 434 | if ((expectedClientId == ids.first) && |
| 435 | (expectedSessionId == ids.second)) |
| 436 | { |
| 437 | // It is owned by the currently request hmc |
| 438 | BMCWEB_LOG_DEBUG << "Lock is owned by the current hmc"; |
| 439 | } |
| 440 | else |
| 441 | { |
| 442 | BMCWEB_LOG_DEBUG << "Lock is not owned by the current hmc"; |
| 443 | return std::make_pair(false, std::make_pair(id, lockTable[id][0])); |
| 444 | } |
| 445 | } |
| 446 | return std::make_pair(true, std::make_pair(0, LockRequest())); |
| 447 | } |
| 448 | |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 449 | inline bool Lock::validateRids(const ListOfTransactionIds& refRids) |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 450 | { |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 451 | for (const auto& id : refRids) |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 452 | { |
| 453 | auto search = lockTable.find(id); |
| 454 | |
| 455 | if (search != lockTable.end()) |
| 456 | { |
| 457 | BMCWEB_LOG_DEBUG << "Valid Transaction id"; |
| 458 | // continue for the next rid |
| 459 | } |
| 460 | else |
| 461 | { |
Gunnar Mills | caa3ce3 | 2020-07-08 14:46:53 -0500 | [diff] [blame] | 462 | BMCWEB_LOG_DEBUG << "At least 1 inValid Request id"; |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 463 | return false; |
| 464 | } |
| 465 | } |
| 466 | return true; |
| 467 | } |
| 468 | |
Ed Tanous | b5a7693 | 2020-09-29 16:16:58 -0700 | [diff] [blame^] | 469 | inline bool Lock::isValidLockRequest(const LockRequest& refLockRecord) |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 470 | { |
| 471 | |
| 472 | // validate the locktype |
| 473 | |
| 474 | if (!((boost::equals(std::get<2>(refLockRecord), "Read") || |
| 475 | (boost::equals(std::get<2>(refLockRecord), "Write"))))) |
| 476 | { |
| 477 | BMCWEB_LOG_DEBUG << "Validation of LockType Failed"; |
| 478 | BMCWEB_LOG_DEBUG << "Locktype : " << std::get<2>(refLockRecord); |
| 479 | return false; |
| 480 | } |
| 481 | |
| 482 | BMCWEB_LOG_DEBUG << static_cast<int>(std::get<4>(refLockRecord).size()); |
| 483 | |
| 484 | // validate the number of segments |
| 485 | // Allowed No of segments are between 2 and 6 |
| 486 | if ((static_cast<int>(std::get<4>(refLockRecord).size()) > 6) || |
| 487 | (static_cast<int>(std::get<4>(refLockRecord).size()) < 2)) |
| 488 | { |
Gunnar Mills | caa3ce3 | 2020-07-08 14:46:53 -0500 | [diff] [blame] | 489 | BMCWEB_LOG_DEBUG << "Validation of Number of Segments Failed"; |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 490 | BMCWEB_LOG_DEBUG << "Number of Segments provied : " |
Ed Tanous | 7cd94e4 | 2020-09-29 16:03:02 -0700 | [diff] [blame] | 491 | << std::get<4>(refLockRecord).size(); |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 492 | return false; |
| 493 | } |
| 494 | |
| 495 | int lockFlag = 0; |
| 496 | // validate the lockflags & segment length |
| 497 | |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 498 | for (const auto& p : std::get<4>(refLockRecord)) |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 499 | { |
| 500 | |
| 501 | // validate the lock flags |
| 502 | // Allowed lockflags are locksame,lockall & dontlock |
| 503 | |
| 504 | if (!((boost::equals(p.first, "LockSame") || |
| 505 | (boost::equals(p.first, "LockAll")) || |
| 506 | (boost::equals(p.first, "DontLock"))))) |
| 507 | { |
| 508 | BMCWEB_LOG_DEBUG << "Validation of lock flags failed"; |
| 509 | BMCWEB_LOG_DEBUG << p.first; |
| 510 | return false; |
| 511 | } |
| 512 | |
| 513 | // validate the segment length |
| 514 | // Allowed values of segment length are between 1 and 4 |
| 515 | |
| 516 | if (p.second < 1 || p.second > 4) |
| 517 | { |
| 518 | BMCWEB_LOG_DEBUG << "Validation of Segment Length Failed"; |
| 519 | BMCWEB_LOG_DEBUG << p.second; |
| 520 | return false; |
| 521 | } |
| 522 | |
| 523 | if ((boost::equals(p.first, "LockSame") || |
| 524 | (boost::equals(p.first, "LockAll")))) |
| 525 | { |
| 526 | ++lockFlag; |
| 527 | if (lockFlag >= 2) |
| 528 | { |
| 529 | return false; |
| 530 | } |
| 531 | } |
| 532 | } |
| 533 | |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 534 | return true; |
| 535 | } |
| 536 | |
Ed Tanous | b5a7693 | 2020-09-29 16:16:58 -0700 | [diff] [blame^] | 537 | inline Rc Lock::isConflictWithTable(const LockRequests& refLockRequestStructure) |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 538 | { |
| 539 | |
| 540 | uint32_t transactionId; |
| 541 | |
| 542 | if (lockTable.empty()) |
| 543 | { |
| 544 | transactionId = generateTransactionId(); |
| 545 | BMCWEB_LOG_DEBUG << transactionId; |
| 546 | // Lock table is empty, so we are safe to add the lockrecords |
| 547 | // as there will be no conflict |
| 548 | BMCWEB_LOG_DEBUG << "Lock table is empty, so adding the lockrecords"; |
| 549 | lockTable.emplace(std::pair<uint32_t, LockRequests>( |
| 550 | transactionId, refLockRequestStructure)); |
| 551 | |
Sunitha Harish | 8a3bb71 | 2019-12-13 03:48:09 -0600 | [diff] [blame] | 552 | // save the lock in the persistent file |
| 553 | saveLocks(); |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 554 | return std::make_pair(false, transactionId); |
| 555 | } |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 556 | BMCWEB_LOG_DEBUG |
| 557 | << "Lock table is not empty, check for conflict with lock table"; |
| 558 | // Lock table is not empty, compare the lockrequest entries with |
| 559 | // the entries in the lock table |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 560 | |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 561 | for (const auto& lockRecord1 : refLockRequestStructure) |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 562 | { |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 563 | for (const auto& map : lockTable) |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 564 | { |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 565 | for (const auto& lockRecord2 : map.second) |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 566 | { |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 567 | bool status = isConflictRecord(lockRecord1, lockRecord2); |
| 568 | if (status) |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 569 | { |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 570 | return std::make_pair( |
| 571 | true, std::make_pair(map.first, lockRecord2)); |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 572 | } |
| 573 | } |
| 574 | } |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 575 | } |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 576 | |
| 577 | // Reached here, so no conflict with the locktable, so we are safe to |
| 578 | // add the request records into the lock table |
| 579 | |
| 580 | // Lock table is empty, so we are safe to add the lockrecords |
| 581 | // as there will be no conflict |
| 582 | BMCWEB_LOG_DEBUG << " Adding elements into lock table"; |
| 583 | transactionId = generateTransactionId(); |
| 584 | lockTable.emplace(std::make_pair(transactionId, refLockRequestStructure)); |
| 585 | |
| 586 | // save the lock in the persistent file |
| 587 | saveLocks(); |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 588 | return std::make_pair(false, transactionId); |
| 589 | } |
| 590 | |
Ed Tanous | b5a7693 | 2020-09-29 16:16:58 -0700 | [diff] [blame^] | 591 | inline bool Lock::isConflictRequest(const LockRequests& refLockRequestStructure) |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 592 | { |
| 593 | // check for all the locks coming in as a part of single request |
| 594 | // return conflict if any two lock requests are conflicting |
| 595 | |
| 596 | if (refLockRequestStructure.size() == 1) |
| 597 | { |
| 598 | BMCWEB_LOG_DEBUG << "Only single lock request, so there is no conflict"; |
| 599 | // This means , we have only one lock request in the current |
| 600 | // request , so no conflict within the request |
| 601 | return false; |
| 602 | } |
| 603 | |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 604 | BMCWEB_LOG_DEBUG |
| 605 | << "There are multiple lock requests coming in a single request"; |
| 606 | |
| 607 | // There are multiple requests a part of one request |
| 608 | |
| 609 | for (uint32_t i = 0; i < refLockRequestStructure.size(); i++) |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 610 | { |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 611 | for (uint32_t j = i + 1; j < refLockRequestStructure.size(); j++) |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 612 | { |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 613 | const LockRequest& p = refLockRequestStructure[i]; |
| 614 | const LockRequest& q = refLockRequestStructure[j]; |
| 615 | bool status = isConflictRecord(p, q); |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 616 | |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 617 | if (status) |
| 618 | { |
| 619 | return true; |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 620 | } |
| 621 | } |
| 622 | } |
| 623 | return false; |
| 624 | } |
| 625 | |
| 626 | // This function converts the provided uint64_t resource id's from the two |
Gunnar Mills | caa3ce3 | 2020-07-08 14:46:53 -0500 | [diff] [blame] | 627 | // lock requests subjected for comparison, and this function also compares |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 628 | // the content by bytes mentioned by a uint32_t number. |
| 629 | |
| 630 | // If all the elements in the lock requests which are subjected for comparison |
Gunnar Mills | caa3ce3 | 2020-07-08 14:46:53 -0500 | [diff] [blame] | 631 | // are same, then the last comparison would be to check for the respective |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 632 | // bytes in the resourceid based on the segment length. |
| 633 | |
Ratan Gupta | 07386c6 | 2019-12-14 14:06:09 +0530 | [diff] [blame] | 634 | inline bool Lock::checkByte(uint64_t resourceId1, uint64_t resourceId2, |
| 635 | uint32_t position) |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 636 | { |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 637 | uint8_t* p = reinterpret_cast<uint8_t*>(&resourceId1); |
| 638 | uint8_t* q = reinterpret_cast<uint8_t*>(&resourceId2); |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 639 | |
| 640 | BMCWEB_LOG_DEBUG << "Comparing bytes " << std::to_string(p[position]) << "," |
| 641 | << std::to_string(q[position]); |
| 642 | if (p[position] != q[position]) |
| 643 | { |
| 644 | return false; |
| 645 | } |
| 646 | |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 647 | return true; |
| 648 | } |
| 649 | |
Ed Tanous | b5a7693 | 2020-09-29 16:16:58 -0700 | [diff] [blame^] | 650 | inline bool Lock::isConflictRecord(const LockRequest& refLockRecord1, |
| 651 | const LockRequest& refLockRecord2) |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 652 | { |
| 653 | // No conflict if both are read locks |
| 654 | |
| 655 | if (boost::equals(std::get<2>(refLockRecord1), "Read") && |
| 656 | boost::equals(std::get<2>(refLockRecord2), "Read")) |
| 657 | { |
| 658 | BMCWEB_LOG_DEBUG << "Both are read locks, no conflict"; |
| 659 | return false; |
| 660 | } |
| 661 | |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 662 | uint32_t i = 0; |
| 663 | for (const auto& p : std::get<4>(refLockRecord1)) |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 664 | { |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 665 | |
| 666 | // return conflict when any of them is try to lock all resources |
| 667 | // under the current resource level. |
| 668 | if (boost::equals(p.first, "LockAll") || |
| 669 | boost::equals(std::get<4>(refLockRecord2)[i].first, "LockAll")) |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 670 | { |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 671 | BMCWEB_LOG_DEBUG |
| 672 | << "Either of the Comparing locks are trying to lock all " |
| 673 | "resources under the current resource level"; |
| 674 | return true; |
| 675 | } |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 676 | |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 677 | // determine if there is a lock-all-with-same-segment-size. |
| 678 | // If the current segment sizes are the same,then we should fail. |
| 679 | |
| 680 | if ((boost::equals(p.first, "LockSame") || |
| 681 | boost::equals(std::get<4>(refLockRecord2)[i].first, "LockSame")) && |
| 682 | (p.second == std::get<4>(refLockRecord2)[i].second)) |
| 683 | { |
| 684 | return true; |
| 685 | } |
| 686 | |
| 687 | // if segment lengths are not the same, it means two different locks |
| 688 | // So no conflict |
| 689 | if (p.second != std::get<4>(refLockRecord2)[i].second) |
| 690 | { |
| 691 | BMCWEB_LOG_DEBUG << "Segment lengths are not same"; |
| 692 | BMCWEB_LOG_DEBUG << "Segment 1 length : " << p.second; |
| 693 | BMCWEB_LOG_DEBUG << "Segment 2 length : " |
| 694 | << std::get<4>(refLockRecord2)[i].second; |
| 695 | return false; |
| 696 | } |
| 697 | |
| 698 | // compare segment data |
| 699 | |
| 700 | for (uint32_t i = 0; i < p.second; i++) |
| 701 | { |
| 702 | // if the segment data is different , then the locks is on a |
| 703 | // different resource So no conflict between the lock |
| 704 | // records. |
| 705 | // BMC is little endian , but the resourceID is formed by |
| 706 | // the Management Console in such a way that, the first byte |
| 707 | // from the MSB Position corresponds to the First Segment |
| 708 | // data. Therefore we need to convert the in-comming |
| 709 | // resourceID into Big Endian before processing further. |
| 710 | if (!(checkByte( |
| 711 | boost::endian::endian_reverse(std::get<3>(refLockRecord1)), |
| 712 | boost::endian::endian_reverse(std::get<3>(refLockRecord2)), |
| 713 | i))) |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 714 | { |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 715 | return false; |
| 716 | } |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 717 | } |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 718 | |
| 719 | ++i; |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 720 | } |
| 721 | |
| 722 | return false; |
| 723 | } |
| 724 | |
Ratan Gupta | 07386c6 | 2019-12-14 14:06:09 +0530 | [diff] [blame] | 725 | inline uint32_t Lock::generateTransactionId() |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 726 | { |
| 727 | ++transactionId; |
| 728 | return transactionId; |
| 729 | } |
| 730 | |
| 731 | } // namespace ibm_mc_lock |
| 732 | } // namespace crow |