From 2e276973e4cb9f943c2ac7f7b15730c8bfc33cb1 Mon Sep 17 00:00:00 2001 From: Cheng Chang Date: Fri, 27 Mar 2020 15:59:21 -0700 Subject: [PATCH] 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 --- utilities/transactions/transaction_lock_mgr.cc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/utilities/transactions/transaction_lock_mgr.cc b/utilities/transactions/transaction_lock_mgr.cc index 82b614033..2a29447ed 100644 --- a/utilities/transactions/transaction_lock_mgr.cc +++ b/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; }