summaryrefslogtreecommitdiff
path: root/qpid/cpp/src/qpid/ha/Primary.cpp
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2012-09-14 18:48:09 +0000
committerAlan Conway <aconway@apache.org>2012-09-14 18:48:09 +0000
commit5c73472bc29bb0dfcfda168ad81e0bb5025a3077 (patch)
tree3eb45e481a828824e6c8e6589ad79150b67ecdeb /qpid/cpp/src/qpid/ha/Primary.cpp
parentcef26777e4d9ed0874e21344994abfaf8fef9a60 (diff)
downloadqpid-python-5c73472bc29bb0dfcfda168ad81e0bb5025a3077.tar.gz
QPID-4223: HA Completion isn't sent when queue that has acquired but unacknowledged messages is deleted
- Extended ha_test.py test_failover_send_receive to kill backup as well as primary - QueueRegistry::destroy was not calling observer. - Primary removes disconnected brokers backups and expectedBackups - Primary calls checkReady in all cases where broker is removed from expectedBackups git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1384882 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src/qpid/ha/Primary.cpp')
-rw-r--r--qpid/cpp/src/qpid/ha/Primary.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/qpid/cpp/src/qpid/ha/Primary.cpp b/qpid/cpp/src/qpid/ha/Primary.cpp
index f36d409b3f..453b0b1ab8 100644
--- a/qpid/cpp/src/qpid/ha/Primary.cpp
+++ b/qpid/cpp/src/qpid/ha/Primary.cpp
@@ -225,19 +225,20 @@ void Primary::opened(broker::Connection& connection) {
}
void Primary::closed(broker::Connection& connection) {
- // NOTE: It is possible for a backup connection to be rejected while we are
- // a backup, but closed() is called after we have become primary.
- //
- // For this reason we do not remove from the backups map here, the backups
- // map holds all the backups we know about whether connected or not.
- //
- Mutex::ScopedLock l(lock);
BrokerInfo info;
if (ha::ConnectionObserver::getBrokerInfo(connection, info)) {
- QPID_LOG(debug, logPrefix << "Backup disconnected: " << info);
- haBroker.removeBroker(info.getSystemId());
+ Mutex::ScopedLock l(lock);
BackupMap::iterator i = backups.find(info.getSystemId());
- if (i != backups.end()) i->second->setConnected(false);
+ // NOTE: It is possible for a backup connection to be rejected while we
+ // are a backup, but closed() is called after we have become primary.
+ // Checking isConnected() lets us ignore such spurious closes.
+ if (i != backups.end() && i->second->isConnected()) {
+ QPID_LOG(info, logPrefix << "Backup disconnected: " << info);
+ haBroker.removeBroker(info.getSystemId());
+ expectedBackups.erase(i->second);
+ backups.erase(i);
+ checkReady(l);
+ }
}
}