From 4f7780a92c482562974923360e6b2d11bd8ffa58 Mon Sep 17 00:00:00 2001 From: Mykola Golub Date: Thu, 14 Mar 2019 18:30:31 +0000 Subject: [PATCH] common: allow "0" cost items to be queued by TokenBucketThrottle They will be queued if there are already blockers. Signed-off-by: Mykola Golub --- src/common/Throttle.h | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/common/Throttle.h b/src/common/Throttle.h index f382140e8bf..1a6acac59d3 100644 --- a/src/common/Throttle.h +++ b/src/common/Throttle.h @@ -410,7 +410,7 @@ public: TokenBucketThrottle(CephContext *cct, const std::string &name, uint64_t capacity, uint64_t avg, SafeTimer *timer, Mutex *timer_lock); - + ~TokenBucketThrottle(); const std::string &get_name() { @@ -424,12 +424,9 @@ public: }); m_blockers.emplace_back(c, ctx); } - + template bool get(uint64_t c, T *handler, I *item, uint64_t flag) { - if (0 == c) - return false; - bool wait = false; uint64_t got = 0; std::lock_guard lock(m_lock); @@ -439,7 +436,7 @@ public: } else { if (0 == m_throttle.max || 0 == m_avg) return false; - + got = m_throttle.get(c); if (got < c) { // Not enough tokens, add a blocker for it. @@ -452,7 +449,7 @@ public: return wait; } - + int set_limit(uint64_t average, uint64_t burst); void set_schedule_tick_min(uint64_t tick); -- 2.39.5