summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/client/ConnectionImpl.cpp
diff options
context:
space:
mode:
authorAndrew Stitcher <astitcher@apache.org>2010-01-21 06:19:09 +0000
committerAndrew Stitcher <astitcher@apache.org>2010-01-21 06:19:09 +0000
commita2cbe9afcfb85da7de0df8c5ae0bec09a5801dff (patch)
tree3818d0980f60e2f68d1f789d08e6e4a73c7482c6 /cpp/src/qpid/client/ConnectionImpl.cpp
parentd413df2f6869223e63b33318fe51ce41cb35adf9 (diff)
downloadqpid-python-a2cbe9afcfb85da7de0df8c5ae0bec09a5801dff.tar.gz
Ensure that shutting down an unsuccessful connect can't race with connection deletion
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@901553 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/client/ConnectionImpl.cpp')
-rw-r--r--cpp/src/qpid/client/ConnectionImpl.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/cpp/src/qpid/client/ConnectionImpl.cpp b/cpp/src/qpid/client/ConnectionImpl.cpp
index 278c85acb9..80cd510886 100644
--- a/cpp/src/qpid/client/ConnectionImpl.cpp
+++ b/cpp/src/qpid/client/ConnectionImpl.cpp
@@ -327,13 +327,19 @@ void ConnectionImpl::shutdown() {
if (handler.isClosed()) return;
+ bool isClosing = handler.isClosing();
+ bool isOpen = handler.isOpen();
+
// FIXME aconway 2008-06-06: exception use, amqp0-10 does not seem to have
// an appropriate close-code. connection-forced is not right.
- bool isClosing = handler.isClosing();
handler.fail(CONN_CLOSED);//ensure connection is marked as failed before notifying sessions
+
+ // At this point if the object isn't open and isn't closing it must have failed to open
+ // so we can't do the rest of the cleanup
+ if (!isClosing && !isOpen) return;
+
Mutex::ScopedLock l(lock);
- if (!isClosing)
- closeInternal(boost::bind(&SessionImpl::connectionBroke, _1, CONN_CLOSED));
+ closeInternal(boost::bind(&SessionImpl::connectionBroke, _1, CONN_CLOSED));
setException(new TransportFailure(CONN_CLOSED));
}