diff options
Diffstat (limited to 'cpp/src/qpid/broker/IncompleteMessageList.cpp')
-rw-r--r-- | cpp/src/qpid/broker/IncompleteMessageList.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/cpp/src/qpid/broker/IncompleteMessageList.cpp b/cpp/src/qpid/broker/IncompleteMessageList.cpp index 2077e633ec..fbeec7afae 100644 --- a/cpp/src/qpid/broker/IncompleteMessageList.cpp +++ b/cpp/src/qpid/broker/IncompleteMessageList.cpp @@ -25,13 +25,20 @@ namespace qpid { namespace broker { IncompleteMessageList::IncompleteMessageList() : - callback(boost::bind(&IncompleteMessageList::enqueueComplete, this, _1)) + callback(boost::bind(&IncompleteMessageList::enqueueComplete, this, _1)), closed(false) {} IncompleteMessageList::~IncompleteMessageList() { + close(); +} + +void IncompleteMessageList::close() +{ sys::Mutex::ScopedLock l(lock); + closed = true; std::for_each(incomplete.begin(), incomplete.end(), boost::bind(&Message::resetEnqueueCompleteCallback, _1)); + lock.notify(); } void IncompleteMessageList::add(boost::intrusive_ptr<Message> msg) @@ -57,8 +64,9 @@ void IncompleteMessageList::process(const CompletionListener& listen, bool sync) sys::Mutex::ScopedUnlock u(lock); msg->flush(); // Can re-enter IncompleteMessageList::enqueueComplete } - while (!msg->isEnqueueComplete()) + while (!msg->isEnqueueComplete() && !closed) lock.wait(); + if (closed) return; } else { //leave the message as incomplete for now return; |