From a2cbe9afcfb85da7de0df8c5ae0bec09a5801dff Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Thu, 21 Jan 2010 06:19:09 +0000 Subject: 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 --- cpp/src/qpid/client/ConnectionImpl.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'cpp/src/qpid/client/ConnectionImpl.cpp') 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)); } -- cgit v1.2.1