summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src')
-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");