Author: aconway
Date: Mon May 28 18:24:21 2012
New Revision: 1343349

URL: http://svn.apache.org/viewvc?rev=1343349&view=rev
Log:
QPID-3603: HA brokers avoid self-connection.

HA brokers attempt to avoid self-connection using SystemInfo::isLocalHost(). If
a VIP is used then this check won't work. Brokers now check the system-id UUID
on incoming connections and reject the connection if it is their own.

Modified:
    qpid/trunk/qpid/cpp/src/qpid/ha/ConnectionExcluder.cpp
    qpid/trunk/qpid/cpp/src/qpid/ha/ConnectionExcluder.h
    qpid/trunk/qpid/cpp/src/qpid/ha/HaBroker.cpp

Modified: qpid/trunk/qpid/cpp/src/qpid/ha/ConnectionExcluder.cpp
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/ha/ConnectionExcluder.cpp?rev=1343349&r1=1343348&r2=1343349&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/ha/ConnectionExcluder.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/ha/ConnectionExcluder.cpp Mon May 28 18:24:21 
2012
@@ -29,8 +29,8 @@
 namespace qpid {
 namespace ha {
 
-ConnectionExcluder::ConnectionExcluder(const LogPrefix& lp)
-    : logPrefix(lp), backupAllowed(false) {}
+ConnectionExcluder::ConnectionExcluder(const LogPrefix& lp, const 
framing::Uuid& uuid)
+    : logPrefix(lp), backupAllowed(false), self(uuid) {}
 
 void ConnectionExcluder::opened(broker::Connection& connection) {
     if (connection.isLink()) return; // Allow all outgoing links
@@ -42,9 +42,14 @@ void ConnectionExcluder::opened(broker::
     framing::FieldTable ft;
     if (connection.getClientProperties().getTable(BACKUP_TAG, ft)) {
         BrokerInfo info(ft);
-        QPID_LOG(debug, logPrefix << "Backup connection " << info <<
-                 (backupAllowed ? " allowed" : " rejected"));
-        if (backupAllowed) return;
+        if (info.getSystemId() == self) {
+            QPID_LOG(debug, logPrefix << "Self connection rejected");
+        }
+        else {
+            QPID_LOG(debug, logPrefix << "Backup connection " << info <<
+                     (backupAllowed ? " allowed" : " rejected"));
+            if (backupAllowed) return;
+        }
     }
     // Abort the connection.
     throw Exception(

Modified: qpid/trunk/qpid/cpp/src/qpid/ha/ConnectionExcluder.h
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/ha/ConnectionExcluder.h?rev=1343349&r1=1343348&r2=1343349&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/ha/ConnectionExcluder.h (original)
+++ qpid/trunk/qpid/cpp/src/qpid/ha/ConnectionExcluder.h Mon May 28 18:24:21 
2012
@@ -24,6 +24,7 @@
 
 #include "LogPrefix.h"
 #include "qpid/broker/ConnectionObserver.h"
+#include "qpid/framing/Uuid.h"
 #include <boost/function.hpp>
 
 namespace qpid {
@@ -45,7 +46,7 @@ class ConnectionExcluder : public broker
     static const std::string ADMIN_TAG;
     static const std::string BACKUP_TAG;
 
-    ConnectionExcluder(const LogPrefix&);
+    ConnectionExcluder(const LogPrefix&, const framing::Uuid& self);
 
     void opened(broker::Connection& connection);
 
@@ -55,6 +56,7 @@ class ConnectionExcluder : public broker
   private:
     LogPrefix logPrefix;
     bool backupAllowed;
+    framing::Uuid self;
 };
 
 }} // namespace qpid::ha

Modified: qpid/trunk/qpid/cpp/src/qpid/ha/HaBroker.cpp
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/ha/HaBroker.cpp?rev=1343349&r1=1343348&r2=1343349&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/ha/HaBroker.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/ha/HaBroker.cpp Mon May 28 18:24:21 2012
@@ -53,7 +53,7 @@ HaBroker::HaBroker(broker::Broker& b, co
       settings(s),
       mgmtObject(0),
       status(STANDALONE),
-      excluder(new ConnectionExcluder(logPrefix)),
+      excluder(new ConnectionExcluder(logPrefix, 
broker.getSystem()->getSystemId())),
       brokerInfo(broker.getSystem()->getNodeName(),
                  broker.getSystem()->getSystemId())
 



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to