From d1c4af32b27b6d242d2b15e4dc91152a6d3e4a5a Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Wed, 27 Jan 2010 20:56:31 +0000 Subject: 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 --- cpp/src/qpid/cluster/Cluster.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'cpp/src/qpid/cluster/Cluster.cpp') 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); } -- cgit v1.2.1