diff options
author | Alan Conway <aconway@apache.org> | 2010-08-23 21:04:33 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2010-08-23 21:04:33 +0000 |
commit | 50ed4bea1348e2a8f7e2df82cb3148798862011c (patch) | |
tree | 0eeebc6ccb64b770313dea786766e89eaa15e949 /cpp/src | |
parent | 867cc757efb2341a1293f2daa412b8aacd75c515 (diff) | |
download | qpid-python-50ed4bea1348e2a8f7e2df82cb3148798862011c.tar.gz |
Check for and abort invalid catchup connections.
Detect attempt to make a catch-up connection while we are not expecting an update.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@988312 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/qpid/cluster/Cluster.cpp | 5 | ||||
-rw-r--r-- | cpp/src/qpid/cluster/Cluster.h | 4 | ||||
-rw-r--r-- | cpp/src/qpid/cluster/ClusterPlugin.cpp | 2 | ||||
-rw-r--r-- | cpp/src/qpid/cluster/Connection.cpp | 6 |
4 files changed, 14 insertions, 3 deletions
diff --git a/cpp/src/qpid/cluster/Cluster.cpp b/cpp/src/qpid/cluster/Cluster.cpp index 3f1d79d382..df0e612af7 100644 --- a/cpp/src/qpid/cluster/Cluster.cpp +++ b/cpp/src/qpid/cluster/Cluster.cpp @@ -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. diff --git a/cpp/src/qpid/cluster/Cluster.h b/cpp/src/qpid/cluster/Cluster.h index 1f8fd447a3..c046874f1c 100644 --- a/cpp/src/qpid/cluster/Cluster.h +++ b/cpp/src/qpid/cluster/Cluster.h @@ -104,7 +104,9 @@ class Cluster : private Cpg::Handler, public management::Manageable { 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; } diff --git a/cpp/src/qpid/cluster/ClusterPlugin.cpp b/cpp/src/qpid/cluster/ClusterPlugin.cpp index 75c8d328cf..2962daaa07 100644 --- a/cpp/src/qpid/cluster/ClusterPlugin.cpp +++ b/cpp/src/qpid/cluster/ClusterPlugin.cpp @@ -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") diff --git a/cpp/src/qpid/cluster/Connection.cpp b/cpp/src/qpid/cluster/Connection.cpp index 923d66ad34..e76cebf68d 100644 --- a/cpp/src/qpid/cluster/Connection.cpp +++ b/cpp/src/qpid/cluster/Connection.cpp @@ -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* data, size_t size) { 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; |