summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/client/ConnectionImpl.cpp
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
commitdf0f6a518fb1574dcdf946975fe38d8f25346480 (patch)
treeecb2087b67952c03e96662e0647f8145aaecee87 /cpp/src/qpid/client/ConnectionImpl.cpp
parent495a47e8feeb3cf3110ed9b972775fa40f58be00 (diff)
downloadqpid-python-df0f6a518fb1574dcdf946975fe38d8f25346480.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/qpid@946106 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/client/ConnectionImpl.cpp')
-rw-r--r--cpp/src/qpid/client/ConnectionImpl.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/cpp/src/qpid/client/ConnectionImpl.cpp b/cpp/src/qpid/client/ConnectionImpl.cpp
index 63a21c1205..d5fe7489d3 100644
--- a/cpp/src/qpid/client/ConnectionImpl.cpp
+++ b/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");