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
This commit is contained in:
Cheng Chang 2020-03-27 15:59:21 -07:00 committed by Facebook GitHub Bot
parent 8abd41a544
commit 2e276973e4

View File

@ -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;
}