summaryrefslogtreecommitdiff
path: root/qpid/cpp/src
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2010-05-19 10:21:05 +0000
committerGordon Sim <gsim@apache.org>2010-05-19 10:21:05 +0000
commit21352eda9ad76aa01dced70032291303fd12e714 (patch)
tree7c294cec6d39dd45785bf12e6bfb8eca91ad7a69 /qpid/cpp/src
parentd7980561d6af75b191388c9c1720dffd60fa6d0a (diff)
downloadqpid-python-21352eda9ad76aa01dced70032291303fd12e714.tar.gz
Prevent race between shutdown() and release() resulting in attempt to close deleted connector.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@946106 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src')
-rw-r--r--qpid/cpp/src/qpid/client/ConnectionImpl.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/qpid/cpp/src/qpid/client/ConnectionImpl.cpp b/qpid/cpp/src/qpid/client/ConnectionImpl.cpp
index 63a21c1205..d5fe7489d3 100644
--- a/qpid/cpp/src/qpid/client/ConnectionImpl.cpp
+++ b/qpid/cpp/src/qpid/client/ConnectionImpl.cpp
@@ -371,15 +371,24 @@ void ConnectionImpl::release() {
bool isActive;
{
Mutex::ScopedLock l(lock);
- released = true;
isActive = connector && !shutdownComplete;
}
//If we are still active - i.e. associated with an IO thread -
//then we cannot delete ourselves yet, but must wait for the
//shutdown callback which we can trigger by calling
//connector.close()
- if (isActive) connector->close();
- else delete this;
+ if (isActive) {
+ connector->close();
+ bool canDelete;
+ {
+ Mutex::ScopedLock l(lock);
+ released = true;
+ canDelete = shutdownComplete;
+ }
+ if (canDelete) delete this;
+ } else {
+ delete this;
+ }
}
static const std::string CONN_CLOSED("Connection closed");