From 846808ff3f3837b1772f293ae71dba5eda609cc4 Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Wed, 18 May 2016 11:49:19 -0700 Subject: [PATCH] BackoffThrottle: use wait_for instead of wait_until On some platforms, wait_until won't surrender the lock with a negative argument. Signed-off-by: Samuel Just --- src/common/Throttle.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common/Throttle.cc b/src/common/Throttle.cc index 3b909ee411247..14cf1ba894d91 100644 --- a/src/common/Throttle.cc +++ b/src/common/Throttle.cc @@ -376,11 +376,11 @@ std::chrono::duration BackoffThrottle::get(uint64_t c) auto start = std::chrono::system_clock::now(); delay = _get_delay(c); - while (((start + delay) > std::chrono::system_clock::now()) || + while ((delay > std::chrono::duration(0)) || !((max == 0) || (current == 0) || ((current + c) <= max))) { assert(ticket == waiters.begin()); - (*ticket)->wait_until(l, start + delay); - delay = _get_delay(c); + (*ticket)->wait_for(l, delay); + delay = _get_delay(c) - (std::chrono::system_clock::now() - start); } waiters.pop_front(); _kick_waiters(); -- 2.39.5