summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2010-05-28 13:37:22 +0000
committerGordon Sim <gsim@apache.org>2010-05-28 13:37:22 +0000
commit9987421eabe1191c950cdb1d538d03a75883255d (patch)
tree1e7a3de99171705bc8029806fe48faccb781ada2 /cpp/src
parentce7d0e4967027c0d73b7eb21ec7be27d8663e20d (diff)
downloadqpid-python-9987421eabe1191c950cdb1d538d03a75883255d.tar.gz
QPID-2598: Prevent exit hang on windows (at the expense of intermittent leak on exit under linux)
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@949176 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/qpid/client/ConnectionImpl.cpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/cpp/src/qpid/client/ConnectionImpl.cpp b/cpp/src/qpid/client/ConnectionImpl.cpp
index 99f4411977..8848554c94 100644
--- a/cpp/src/qpid/client/ConnectionImpl.cpp
+++ b/cpp/src/qpid/client/ConnectionImpl.cpp
@@ -83,7 +83,6 @@ class IOThread {
int ioThreads;
int connections;
Mutex threadLock;
- Condition noConnections;
std::vector<Thread> t;
Poller::shared_ptr poller_;
@@ -103,8 +102,6 @@ public:
void sub() {
ScopedLock<Mutex> l(threadLock);
--connections;
- if (connections == 0)
- noConnections.notifyAll();
}
Poller::shared_ptr poller() const {
@@ -128,14 +125,15 @@ public:
// and we can't do that before we're unloaded as we can't
// restart the Poller after shutting it down
~IOThread() {
- ScopedLock<Mutex> l(threadLock);
- while (connections > 0) {
- noConnections.wait(threadLock);
+ std::vector<Thread> threads;
+ {
+ ScopedLock<Mutex> l(threadLock);
+ if (poller_)
+ poller_->shutdown();
+ t.swap(threads);
}
- if (poller_)
- poller_->shutdown();
- for (int i=0; i<ioThreads; ++i) {
- t[i].join();
+ for (std::vector<Thread>::iterator i = threads.begin(); i != threads.end(); ++i) {
+ i->join();
}
}
};