Author: astitcher
Date: Thu Jan 21 06:19:09 2010
New Revision: 901553

URL: http://svn.apache.org/viewvc?rev=901553&view=rev
Log:
Ensure that shutting down an unsuccessful connect can't race with connection 
deletion

Modified:
    qpid/trunk/qpid/cpp/src/qpid/client/ConnectionImpl.cpp

Modified: qpid/trunk/qpid/cpp/src/qpid/client/ConnectionImpl.cpp
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/client/ConnectionImpl.cpp?rev=901553&r1=901552&r2=901553&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/client/ConnectionImpl.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/client/ConnectionImpl.cpp Thu Jan 21 06:19:09 
2010
@@ -327,13 +327,19 @@
 
     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));
 }
 



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:[email protected]

Reply via email to