summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/broker/IncompleteMessageList.cpp
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2008-11-27 18:43:00 +0000
committerGordon Sim <gsim@apache.org>2008-11-27 18:43:00 +0000
commit8c0a54230037ed99d5495fa13f68017cfc05473d (patch)
tree92ff53c9d4885aa9e0c0bd90b1a551688d632049 /cpp/src/qpid/broker/IncompleteMessageList.cpp
parentb3fa56fdcc70b3e7f8467d629731fb1c8f90b02f (diff)
downloadqpid-python-8c0a54230037ed99d5495fa13f68017cfc05473d.tar.gz
Ensure broker doesn't hang waiting for async enqueue to complete on shutdown.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@721256 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/broker/IncompleteMessageList.cpp')
-rw-r--r--cpp/src/qpid/broker/IncompleteMessageList.cpp12
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;