From 3ab5ef39649dfeedbfc9e0ae56d7f69ac7393d20 Mon Sep 17 00:00:00 2001 From: xie xingguo Date: Wed, 21 Sep 2016 16:19:04 +0800 Subject: [PATCH] common/throttle: simplify Throttle::_wait() We don't have to check/set the "waited" member when falling into this branch, which is deemed to be true. Signed-off-by: xie xingguo --- src/common/Throttle.cc | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/common/Throttle.cc b/src/common/Throttle.cc index 8a52906cd5e5d..69d98da418c5e 100644 --- a/src/common/Throttle.cc +++ b/src/common/Throttle.cc @@ -97,22 +97,19 @@ bool Throttle::_wait(int64_t c) if (_should_wait(c) || !cond.empty()) { // always wait behind other waiters. Cond *cv = new Cond; cond.push_back(cv); + waited = true; + ldout(cct, 2) << "_wait waiting..." << dendl; + if (logger) + start = ceph_clock_now(cct); + do { - if (!waited) { - ldout(cct, 2) << "_wait waiting..." << dendl; - if (logger) - start = ceph_clock_now(cct); - } - waited = true; cv->Wait(lock); } while (_should_wait(c) || cv != cond.front()); - if (waited) { - ldout(cct, 3) << "_wait finished waiting" << dendl; - if (logger) { - utime_t dur = ceph_clock_now(cct) - start; - logger->tinc(l_throttle_wait, dur); - } + ldout(cct, 2) << "_wait finished waiting" << dendl; + if (logger) { + utime_t dur = ceph_clock_now(cct) - start; + logger->tinc(l_throttle_wait, dur); } delete cv; -- 2.39.5