From b6eb88609aea82e676f33ae8ff68918b68b81d33 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Mon, 26 Oct 2009 20:11:08 +0000 Subject: Separate FailoverListener from client::Connection. client::ConnectionImpl used to contain a FailoverListener to subscribe for updates on the amq.failover exchange. This caused some lifecycle issues including memory leaks. Now FailoverListener is a public API class that the user must create associated with a session to get known-broker updates. Removed the weak_ptr logic in client::SessionImpl which was only required because of FailoverListener. Made SessionImpl::close() idempotent. Gets rid of spurious warning messages in some tests. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@829931 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/client/FailoverManager.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'cpp/src/qpid/client/FailoverManager.cpp') diff --git a/cpp/src/qpid/client/FailoverManager.cpp b/cpp/src/qpid/client/FailoverManager.cpp index 967c3613c0..81f71eb7df 100644 --- a/cpp/src/qpid/client/FailoverManager.cpp +++ b/cpp/src/qpid/client/FailoverManager.cpp @@ -77,7 +77,9 @@ Connection& FailoverManager::connect(std::vector brokers) } else { state = CONNECTING; Connection c; - attempt(c, settings, brokers.empty() ? connection.getKnownBrokers() : brokers); + if (brokers.empty() && failoverListener.get()) + brokers = failoverListener->getKnownBrokers(); + attempt(c, settings, brokers); if (c.isOpen()) state = IDLE; else state = CANT_CONNECT; connection = c; @@ -118,6 +120,7 @@ void FailoverManager::attempt(Connection& c, ConnectionSettings s) try { QPID_LOG(info, "Attempting to connect to " << s.host << " on " << s.port << "..."); c.open(s); + failoverListener.reset(new FailoverListener(c)); QPID_LOG(info, "Connected to " << s.host << " on " << s.port); } catch (const Exception& e) { QPID_LOG(info, "Could not connect to " << s.host << " on " << s.port << ": " << e.what()); -- cgit v1.2.1