When we change the average or max to 0, we need to complete all m_blockers
first.
Fixes: http://tracker.ceph.com/issues/36715
Signed-off-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
std::lock_guard<Mutex> lock(m_lock);
// put tokens into bucket.
m_throttle.put(tokens_this_tick());
+ if (0 == m_avg || 0 == m_throttle.max)
+ tmp_blockers.swap(m_blockers);
// check the m_blockers from head to tail, if blocker can get
// enough tokens, let it go.
while (!m_blockers.empty()) {
template <typename T, typename I, void(T::*MF)(int, I*, uint64_t)>
bool get(uint64_t c, T *handler, I *item, uint64_t flag) {
- if (0 == m_avg)
+ if (0 == c)
return false;
-
+
bool wait = false;
uint64_t got = 0;
std::lock_guard<Mutex> lock(m_lock);
// Keep the order of requests, add item after previous blocked requests.
wait = true;
} 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.