From: Samuel Just Date: Wed, 18 May 2016 19:09:10 +0000 (-0700) Subject: BackoffThrottle: wait() if past max X-Git-Tag: v11.0.0~441^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=6f835726a7df5b29a96849fc1362186fd2116d9b;p=ceph-ci.git BackoffThrottle: wait() if past max Otherwise, we risk spinning on wait_for() with a small delay. Fixes: http://tracker.ceph.com/issues/15953 Signed-off-by: Samuel Just --- diff --git a/src/common/Throttle.cc b/src/common/Throttle.cc index 14cf1ba894d..8a52906cd5e 100644 --- a/src/common/Throttle.cc +++ b/src/common/Throttle.cc @@ -376,10 +376,15 @@ std::chrono::duration BackoffThrottle::get(uint64_t c) auto start = std::chrono::system_clock::now(); delay = _get_delay(c); - while ((delay > std::chrono::duration(0)) || - !((max == 0) || (current == 0) || ((current + c) <= max))) { + while (true) { + if (!((max == 0) || (current == 0) || (current + c) <= max)) { + (*ticket)->wait(l); + } else if (delay > std::chrono::duration(0)) { + (*ticket)->wait_for(l, delay); + } else { + break; + } assert(ticket == waiters.begin()); - (*ticket)->wait_for(l, delay); delay = _get_delay(c) - (std::chrono::system_clock::now() - start); } waiters.pop_front();