summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/client/Bounds.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/qpid/client/Bounds.cpp')
-rw-r--r--cpp/src/qpid/client/Bounds.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/cpp/src/qpid/client/Bounds.cpp b/cpp/src/qpid/client/Bounds.cpp
index abb983a62e..cc2577d5fc 100644
--- a/cpp/src/qpid/client/Bounds.cpp
+++ b/cpp/src/qpid/client/Bounds.cpp
@@ -33,19 +33,19 @@ Bounds::Bounds(size_t maxSize) : max(maxSize), current(0) {}
bool Bounds::expand(size_t sizeRequired, bool block) {
if (!max) return true;
Waitable::ScopedLock l(lock);
- current += sizeRequired;
if (block) {
Waitable::ScopedWait w(lock);
- while (current > max)
+ while (current + sizeRequired > max)
lock.wait();
}
+ current += sizeRequired;
return current <= max;
}
void Bounds::reduce(size_t size) {
if (!max || size == 0) return;
Waitable::ScopedLock l(lock);
- if (current == 0) return;
+ assert(current >= size);
current -= std::min(size, current);
if (current < max && lock.hasWaiters()) {
lock.notifyAll();