Author: aconway
Date: Mon Aug 23 21:04:33 2010
New Revision: 988312

URL: http://svn.apache.org/viewvc?rev=988312&view=rev
Log:
Check for and abort invalid catchup connections.

Detect attempt to make a catch-up connection while we are not expecting an 
update.

Modified:
    qpid/trunk/qpid/cpp/src/qpid/cluster/Cluster.cpp
    qpid/trunk/qpid/cpp/src/qpid/cluster/Cluster.h
    qpid/trunk/qpid/cpp/src/qpid/cluster/ClusterPlugin.cpp
    qpid/trunk/qpid/cpp/src/qpid/cluster/Connection.cpp

Modified: qpid/trunk/qpid/cpp/src/qpid/cluster/Cluster.cpp
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/cluster/Cluster.cpp?rev=988312&r1=988311&r2=988312&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/cluster/Cluster.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/cluster/Cluster.cpp Mon Aug 23 21:04:33 2010
@@ -908,6 +908,11 @@ void Cluster::updateInRetracted() {
     checkUpdateIn(l);
 }
 
+bool Cluster::isExpectingUpdate() {
+    Lock l(lock);
+    return state <= UPDATEE;
+}
+
 void Cluster::checkUpdateIn(Lock& l) {
     if (state != UPDATEE) return; // Wait till we reach the stall point.
     if (!updateClosed) return;  // Wait till update connection closes.

Modified: qpid/trunk/qpid/cpp/src/qpid/cluster/Cluster.h
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/cluster/Cluster.h?rev=988312&r1=988311&r2=988312&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/cluster/Cluster.h (original)
+++ qpid/trunk/qpid/cpp/src/qpid/cluster/Cluster.h Mon Aug 23 21:04:33 2010
@@ -104,7 +104,9 @@ class Cluster : private Cpg::Handler, pu
     void updateInClosed();
     void updateInDone(const ClusterMap&);
     void updateInRetracted();
-
+    // True if we are expecting to receive catch-up connections.
+    bool isExpectingUpdate();
+    
     MemberId getId() const;
     broker::Broker& getBroker() const;
     Multicaster& getMulticast() { return mcast; }

Modified: qpid/trunk/qpid/cpp/src/qpid/cluster/ClusterPlugin.cpp
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/cluster/ClusterPlugin.cpp?rev=988312&r1=988311&r2=988312&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/cluster/ClusterPlugin.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/cluster/ClusterPlugin.cpp Mon Aug 23 21:04:33 
2010
@@ -63,7 +63,7 @@ struct ClusterOptions : public Options {
         addOptions()
             ("cluster-name", optValue(settings.name, "NAME"), "Name of cluster 
to join")
             ("cluster-url", optValue(settings.url,"URL"),
-             "URL of this broker, advertized to the cluster.\n"
+             "Set URL of this individual broker, to be advertized to 
clients.\n"
              "Defaults to a URL listing all the local IP addresses\n")
             ("cluster-username", optValue(settings.username, ""), "Username 
for connections between brokers")
             ("cluster-password", optValue(settings.password, ""), "Password 
for connections between brokers")

Modified: qpid/trunk/qpid/cpp/src/qpid/cluster/Connection.cpp
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/cluster/Connection.cpp?rev=988312&r1=988311&r2=988312&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/cluster/Connection.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/cluster/Connection.cpp Mon Aug 23 21:04:33 2010
@@ -257,7 +257,7 @@ void Connection::closed() {
             close();
             cluster.updateInClosed();
         }
-        else if (catchUp) {
+        else if (catchUp && cluster.isExpectingUpdate()) {
             QPID_LOG(critical, cluster << " catch-up connection closed 
prematurely " << *this);
             cluster.leave();
         }
@@ -304,6 +304,10 @@ size_t Connection::decode(const char* da
     const char* ptr = data;
     const char* end = data + size;
     if (catchUp) {              // Handle catch-up locally.
+        if (!cluster.isExpectingUpdate()) {
+            QPID_LOG(error, "Rejecting unexpected catch-up connection.");
+            abort();            // Cluster is not expecting catch-up 
connections.
+        }
         bool wasOpen = connection->isOpen();
         Buffer buf(const_cast<char*>(ptr), size);
         ptr += size;



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

Reply via email to