Compute cv_end_time with simpler logic (#6585)

Summary:
The refactored logic is easier to read.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/6585

Test Plan: make check

Reviewed By: lth

Differential Revision: D20663225

Pulled By: cheng-chang

fbshipit-source-id: cfd28955cd03b0a71d9087085170875f6dd0be9e
main
Cheng Chang 4 years ago committed by Facebook GitHub Bot
parent 8abd41a544
commit 2e276973e4
  1. 10
      utilities/transactions/transaction_lock_mgr.cc

@ -348,13 +348,11 @@ Status TransactionLockMgr::AcquireWithTimeout(
do {
// Decide how long to wait
int64_t cv_end_time = -1;
// Check if held lock's expiration time is sooner than our timeout
if (expire_time_hint > 0 &&
(timeout < 0 || (timeout > 0 && expire_time_hint < end_time))) {
// expiration time is sooner than our timeout
if (expire_time_hint > 0 && end_time > 0) {
cv_end_time = std::min(expire_time_hint, end_time);
} else if (expire_time_hint > 0) {
cv_end_time = expire_time_hint;
} else if (timeout >= 0) {
} else if (end_time > 0) {
cv_end_time = end_time;
}

Loading…
Cancel
Save