summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2009-02-04 21:31:23 +0000
committerAlan Conway <aconway@apache.org>2009-02-04 21:31:23 +0000
commit3de263a28e2421bb916e1da0cf0f09881801785c (patch)
tree9f809de1dc1ab5694a38e0f6a94b7f19711bf2dc /cpp
parent5b50014477ef0b9096c017af8fb85ac5693e673e (diff)
downloadqpid-python-3de263a28e2421bb916e1da0cf0f09881801785c.tar.gz
Fix race condition with deleted local connections.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@740900 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp')
-rw-r--r--cpp/src/qpid/cluster/Cluster.cpp7
-rw-r--r--cpp/src/qpid/cluster/ConnectionMap.cpp4
-rw-r--r--cpp/src/qpid/cluster/ConnectionMap.h4
3 files changed, 10 insertions, 5 deletions
diff --git a/cpp/src/qpid/cluster/Cluster.cpp b/cpp/src/qpid/cluster/Cluster.cpp
index 41688b5c49..4709ca759d 100644
--- a/cpp/src/qpid/cluster/Cluster.cpp
+++ b/cpp/src/qpid/cluster/Cluster.cpp
@@ -251,7 +251,8 @@ void Cluster::deliveredFrame(const EventFrame& e) {
return;
}
boost::intrusive_ptr<Connection> connection = connections.get(e.connectionId);
- connection->deliveredFrame(e);
+ if (connection) // Ignore frames to closed local connections.
+ connection->deliveredFrame(e);
}
QPID_LATENCY_RECORD("processed", e.frame);
}
@@ -321,11 +322,11 @@ void Cluster::configChange(const MemberId&, const std::string& addresses, Lock&
if (state == INIT) { // First configChange
if (map.aliveCount() == 1) {
- QPID_LOG(notice, *this << " first in cluster");
setClusterId(true);
setReady(l);
map = ClusterMap(myId, myUrl, true);
memberUpdate(l);
+ QPID_LOG(notice, *this << " first in cluster");
}
else { // Joining established group.
state = JOINER;
@@ -380,8 +381,8 @@ void Cluster::ready(const MemberId& id, const std::string& url, Lock& l) {
if (map.ready(id, Url(url)))
memberUpdate(l);
if (state == CATCHUP && id == myId) {
- QPID_LOG(notice, *this << " caught up, active cluster member");
setReady(l);
+ QPID_LOG(notice, *this << " caught up, active cluster member");
}
}
diff --git a/cpp/src/qpid/cluster/ConnectionMap.cpp b/cpp/src/qpid/cluster/ConnectionMap.cpp
index 9dc6210666..1a49a4d663 100644
--- a/cpp/src/qpid/cluster/ConnectionMap.cpp
+++ b/cpp/src/qpid/cluster/ConnectionMap.cpp
@@ -48,7 +48,9 @@ void ConnectionMap::erase(const ConnectionId& id) {
ConnectionMap::ConnectionPtr ConnectionMap::get(const ConnectionId& id) {
Map::const_iterator i = map.find(id);
if (i == map.end()) {
- assert(id.getMember() != cluster.getId());
+ // Deleted local connection.
+ if(id.getMember() == cluster.getId())
+ return 0;
// New remote connection, create a shadow.
std::ostringstream mgmtId;
mgmtId << id;
diff --git a/cpp/src/qpid/cluster/ConnectionMap.h b/cpp/src/qpid/cluster/ConnectionMap.h
index 23084796cf..c5437eb84a 100644
--- a/cpp/src/qpid/cluster/ConnectionMap.h
+++ b/cpp/src/qpid/cluster/ConnectionMap.h
@@ -55,7 +55,9 @@ class ConnectionMap {
/** Erase a closed connection. Called in deliver thread. */
void erase(const ConnectionId& id);
- /** Get an existing connection. */
+ /** Get an existing connection. Returns 0 if id is a closed local
+ * connections, frames for closed connections should be ignored.
+ */
ConnectionPtr get(const ConnectionId& id);
/** Get connections for sending an update. */