summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2012-05-28 18:24:21 +0000
committerAlan Conway <aconway@apache.org>2012-05-28 18:24:21 +0000
commit809082c99f22aa6026638110315b9ec9229254e9 (patch)
tree225079cdf2cd1d6d7a5d523ce161f33f20bccb58 /cpp
parent6058747984cca7d2afe03390e12b75749e71e5b9 (diff)
downloadqpid-python-809082c99f22aa6026638110315b9ec9229254e9.tar.gz
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. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1343349 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp')
-rw-r--r--cpp/src/qpid/ha/ConnectionExcluder.cpp15
-rw-r--r--cpp/src/qpid/ha/ConnectionExcluder.h4
-rw-r--r--cpp/src/qpid/ha/HaBroker.cpp2
3 files changed, 14 insertions, 7 deletions
diff --git a/cpp/src/qpid/ha/ConnectionExcluder.cpp b/cpp/src/qpid/ha/ConnectionExcluder.cpp
index 6c413982f8..18b4432aa1 100644
--- a/cpp/src/qpid/ha/ConnectionExcluder.cpp
+++ b/cpp/src/qpid/ha/ConnectionExcluder.cpp
@@ -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::Connection& connection) {
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(
diff --git a/cpp/src/qpid/ha/ConnectionExcluder.h b/cpp/src/qpid/ha/ConnectionExcluder.h
index 4a2ebcc127..042544c333 100644
--- a/cpp/src/qpid/ha/ConnectionExcluder.h
+++ b/cpp/src/qpid/ha/ConnectionExcluder.h
@@ -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::ConnectionObserver
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::ConnectionObserver
private:
LogPrefix logPrefix;
bool backupAllowed;
+ framing::Uuid self;
};
}} // namespace qpid::ha
diff --git a/cpp/src/qpid/ha/HaBroker.cpp b/cpp/src/qpid/ha/HaBroker.cpp
index 32261c560d..71995c1ac2 100644
--- a/cpp/src/qpid/ha/HaBroker.cpp
+++ b/cpp/src/qpid/ha/HaBroker.cpp
@@ -53,7 +53,7 @@ HaBroker::HaBroker(broker::Broker& b, const Settings& s)
settings(s),
mgmtObject(0),
status(STANDALONE),
- excluder(new ConnectionExcluder(logPrefix)),
+ excluder(new ConnectionExcluder(logPrefix, broker.getSystem()->getSystemId())),
brokerInfo(broker.getSystem()->getNodeName(),
broker.getSystem()->getSystemId())