From 2722a0a487e77ea2aa0d18caec0bdac50cb6a264 Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Thu, 13 Mar 2014 14:04:19 -0700 Subject: [PATCH] PrioritizedQueue: cap costs at max_tokens_per_subqueue Otherwise, you can get a recovery op in the queue which has a cost higher than the max token value. It won't get serviced until all other queues also do not have enough tokens and higher priority queues are empty. Fixes: #7706 Signed-off-by: Samuel Just --- src/common/PrioritizedQueue.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/common/PrioritizedQueue.h b/src/common/PrioritizedQueue.h index e663f277693e..d936d5d86c4f 100644 --- a/src/common/PrioritizedQueue.h +++ b/src/common/PrioritizedQueue.h @@ -311,12 +311,16 @@ public: void enqueue(K cl, unsigned priority, unsigned cost, T item) { if (cost < min_cost) cost = min_cost; + if (cost > max_tokens_per_subqueue) + cost = max_tokens_per_subqueue; create_queue(priority)->enqueue(cl, cost, item); } void enqueue_front(K cl, unsigned priority, unsigned cost, T item) { if (cost < min_cost) cost = min_cost; + if (cost > max_tokens_per_subqueue) + cost = max_tokens_per_subqueue; create_queue(priority)->enqueue_front(cl, cost, item); } -- 2.47.3