qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject svn commit: r603551 - in /incubator/qpid/trunk/qpid/cpp/src/qpid/client: ConnectionImpl.cpp ConnectionImpl.h
Date Wed, 12 Dec 2007 10:50:59 GMT
Author: gsim
Date: Wed Dec 12 02:50:58 2007
New Revision: 603551

URL: http://svn.apache.org/viewvc?rev=603551&view=rev
Log:
Fixed deadlock on connection close


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

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/client/ConnectionImpl.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/client/ConnectionImpl.cpp?rev=603551&r1=603550&r2=603551&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/client/ConnectionImpl.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/client/ConnectionImpl.cpp Wed Dec 12 02:50:58 2007
@@ -32,7 +32,7 @@
 using namespace qpid::sys;
 
 ConnectionImpl::ConnectionImpl(boost::shared_ptr<Connector> c)
-    : connector(c), isClosed(false)
+    : connector(c), isClosed(false), isClosing(false)
 {
     handler.in = boost::bind(&ConnectionImpl::incoming, this, _1);
     handler.out = boost::bind(&Connector::send, connector, _1);
@@ -86,11 +86,21 @@
     handler.waitForOpen();
 }
 
-void ConnectionImpl::close()
+bool ConnectionImpl::setClosing()
 {
     Mutex::ScopedLock l(lock);
-    if (!isClosed)
+    if (isClosing || isClosed) {
+        return false;
+    }
+    isClosing = true;
+    return true;
+}
+
+void ConnectionImpl::close()
+{
+    if (setClosing()) {
         handler.close();
+    }
 }
 
 void ConnectionImpl::idleIn()

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/client/ConnectionImpl.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/client/ConnectionImpl.h?rev=603551&r1=603550&r2=603551&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/client/ConnectionImpl.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/client/ConnectionImpl.h Wed Dec 12 02:50:58 2007
@@ -49,12 +49,14 @@
     framing::ProtocolVersion version;
     sys::Mutex lock;
     bool isClosed;
+    bool isClosing;
 
     void incoming(framing::AMQFrame& frame);    
     void closed(uint16_t, const std::string&);
     void idleOut();
     void idleIn();
     void shutdown();
+    bool setClosing();
 
     template <class F> void forChannels(F functor);
 



Mime
View raw message