diff options
| author | Alan Conway <aconway@apache.org> | 2010-01-27 20:56:31 +0000 |
|---|---|---|
| committer | Alan Conway <aconway@apache.org> | 2010-01-27 20:56:31 +0000 |
| commit | d1c4af32b27b6d242d2b15e4dc91152a6d3e4a5a (patch) | |
| tree | 68ae4c033fcf4f36c19966bf474c9ebdafd40fdf /cpp/src/qpid/cluster/Cluster.cpp | |
| parent | 1e24432f3f0333890334648d808410fb3e9535cd (diff) | |
| download | qpid-python-d1c4af32b27b6d242d2b15e4dc91152a6d3e4a5a.tar.gz | |
Fix cluster elder calculation to ensure unique elder.
Race condition in the previous algorithm allowed several cluster
members to consider themselves the elder.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@903826 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/cluster/Cluster.cpp')
| -rw-r--r-- | cpp/src/qpid/cluster/Cluster.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/cpp/src/qpid/cluster/Cluster.cpp b/cpp/src/qpid/cluster/Cluster.cpp index 53100fa0c1..d398f30a86 100644 --- a/cpp/src/qpid/cluster/Cluster.cpp +++ b/cpp/src/qpid/cluster/Cluster.cpp @@ -189,11 +189,13 @@ struct ClusterDispatcher : public framing::AMQP_AllOperations::ClusterHandler { void initialStatus(uint32_t version, bool active, const Uuid& clusterId, uint8_t storeState, const Uuid& shutdownId, - const framing::SequenceNumber& configSeq) + const framing::SequenceNumber& configSeq, + const std::string& firstConfig) { cluster.initialStatus( member, version, active, clusterId, - framing::cluster::StoreState(storeState), shutdownId, configSeq, l); + framing::cluster::StoreState(storeState), shutdownId, configSeq, + firstConfig, l); } void ready(const std::string& url) { cluster.ready(member, url, l); } void configChange(const std::string& current) { cluster.configChange(member, current, l); } @@ -553,7 +555,7 @@ void Cluster::configChange ( << AddrList(joined, nJoined, "joined: ") << AddrList(left, nLeft, "left: ") << ")"); - std::string addresses; + string addresses; for (const cpg_address* p = current; p < current+nCurrent; ++p) addresses.append(MemberId(*p).str()); deliverEvent(Event::control(ClusterConfigChangeBody(ProtocolVersion(), addresses), self)); @@ -625,7 +627,8 @@ void Cluster::configChange(const MemberId&, const std::string& configStr, Lock& mcast.mcastControl( ClusterInitialStatusBody( ProtocolVersion(), CLUSTER_VERSION, state > INIT, clusterId, - store.getState(), store.getShutdownId(), store.getConfigSeq() + store.getState(), store.getShutdownId(), store.getConfigSeq(), + initMap.getFirstConfigStr() ), self); } @@ -673,6 +676,7 @@ void Cluster::initialStatus(const MemberId& member, uint32_t version, bool activ framing::cluster::StoreState store, const framing::Uuid& shutdownId, const framing::SequenceNumber& configSeq, + const std::string& firstConfig, Lock& l) { if (version != CLUSTER_VERSION) { @@ -684,7 +688,7 @@ void Cluster::initialStatus(const MemberId& member, uint32_t version, bool activ initMap.received( member, ClusterInitialStatusBody(ProtocolVersion(), version, active, id, - store, shutdownId, configSeq) + store, shutdownId, configSeq, firstConfig) ); if (initMap.transitionToComplete()) initMapCompleted(l); } |
