summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/client/Bounds.cpp
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2010-05-27 18:09:13 +0000
committerGordon Sim <gsim@apache.org>2010-05-27 18:09:13 +0000
commitc95b2615abf0883f7d92aad73138a4dda14e1311 (patch)
tree7eb2195eab5c7ecafab17e553635a434b20dee64 /cpp/src/qpid/client/Bounds.cpp
parent91491e533896be58438ba2dc0e199461b4320653 (diff)
downloadqpid-python-c95b2615abf0883f7d92aad73138a4dda14e1311.tar.gz
QPID-2631: For blocking Bounds::expand() calls, only increase the current count when there is space. In SessionImpl::send() expand bounds before queueing frame. Expand bounds for all frames sent (including connection frames and cluster specific frames).
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@948936 13f79535-47bb-0310-9956-ffa450edef68
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();