qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject svn commit: r803802 - in /qpid/trunk/qpid/cpp/src/qpid/client: ConnectionHandler.cpp StateManager.cpp StateManager.h
Date Thu, 13 Aug 2009 07:47:43 GMT
Author: gsim
Date: Thu Aug 13 07:47:43 2009
New Revision: 803802

URL: http://svn.apache.org/viewvc?rev=803802&view=rev
Log:
QPID-2048: Handle connection fail while attempting to close.


Modified:
    qpid/trunk/qpid/cpp/src/qpid/client/ConnectionHandler.cpp
    qpid/trunk/qpid/cpp/src/qpid/client/StateManager.cpp
    qpid/trunk/qpid/cpp/src/qpid/client/StateManager.h

Modified: qpid/trunk/qpid/cpp/src/qpid/client/ConnectionHandler.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/client/ConnectionHandler.cpp?rev=803802&r1=803801&r2=803802&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/client/ConnectionHandler.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/client/ConnectionHandler.cpp Thu Aug 13 07:47:43 2009
@@ -147,11 +147,15 @@
         fail("Connection closed before it was established");
         break;
       case OPEN:
-        setState(CLOSING);
-        proxy.close(200, OK);
-        waitFor(FINISHED);
+        if (setState(CLOSING, OPEN)) {
+            proxy.close(200, OK);
+            waitFor(FINISHED);//FINISHED = CLOSED or FAILED
+        }
+        //else, state was changed from open after we checked, can only
+        //change to failed or closed, so nothing to do
         break;
-        // Nothing to do for CLOSING, CLOSED, FAILED or NOT_STARTED
+
+        // Nothing to do if already CLOSING, CLOSED, FAILED or if NOT_STARTED
     }
 }
 

Modified: qpid/trunk/qpid/cpp/src/qpid/client/StateManager.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/client/StateManager.cpp?rev=803802&r1=803801&r2=803802&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/client/StateManager.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/client/StateManager.cpp Thu Aug 13 07:47:43 2009
@@ -60,6 +60,18 @@
     stateLock.notifyAll();
 }
 
+bool StateManager::setState(int s, int expected)
+{
+    Monitor::ScopedLock l(stateLock);
+    if (state == expected) {
+        state = s;
+        stateLock.notifyAll();
+        return true;
+    } else {
+        return false;
+    }
+}
+
 int StateManager::getState() const
 {
     Monitor::ScopedLock l(stateLock);

Modified: qpid/trunk/qpid/cpp/src/qpid/client/StateManager.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/client/StateManager.h?rev=803802&r1=803801&r2=803802&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/client/StateManager.h (original)
+++ qpid/trunk/qpid/cpp/src/qpid/client/StateManager.h Thu Aug 13 07:47:43 2009
@@ -36,6 +36,7 @@
 public:
     StateManager(int initial);
     void setState(int state);
+    bool setState(int state, int expected);
     int getState() const ;
     void waitForStateChange(int current);
     void waitFor(std::set<int> states);



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message