From 72897efdcb587221bd8bec5af6ffa57092e8cab7 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Wed, 10 Nov 2010 22:30:38 +0000 Subject: Fixed segfault when setting the agent filter on a closed session. Fixed notification for the connected-broker agent. Added an example console program in c++ to monitor the set of agents. Fixed the Python agent example to more elegantly handle connection failure. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1033763 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qmf/ConsoleSession.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'cpp/src/qmf/ConsoleSession.cpp') diff --git a/cpp/src/qmf/ConsoleSession.cpp b/cpp/src/qmf/ConsoleSession.cpp index 6eb9b94bf8..dc2bbe34ee 100644 --- a/cpp/src/qmf/ConsoleSession.cpp +++ b/cpp/src/qmf/ConsoleSession.cpp @@ -110,9 +110,17 @@ void ConsoleSessionImpl::setAgentFilter(const string& predicate) enqueueEventLH(eventImpl.release()); } - if (!connectedBrokerInAgentList && agentQuery.matchesPredicate(connectedBrokerAgent.getAttributes())) { + if (!connectedBrokerInAgentList && connectedBrokerAgent.isValid() && + agentQuery.matchesPredicate(connectedBrokerAgent.getAttributes())) { agents[connectedBrokerAgent.getName()] = connectedBrokerAgent; connectedBrokerInAgentList = true; + + // + // Enqueue a notification of the new agent. + // + auto_ptr eventImpl(new ConsoleEventImpl(CONSOLE_AGENT_ADD)); + eventImpl->setAgent(connectedBrokerAgent); + enqueueEventLH(ConsoleEvent(eventImpl.release())); } } @@ -393,6 +401,13 @@ void ConsoleSessionImpl::handleAgentUpdate(const string& agentName, const Varian if (!agentQuery || agentQuery.matchesPredicate(attrs)) { connectedBrokerInAgentList = true; agents[agentName] = agent; + + // + // Enqueue a notification of the new agent. + // + auto_ptr eventImpl(new ConsoleEventImpl(CONSOLE_AGENT_ADD)); + eventImpl->setAgent(agent); + enqueueEventLH(ConsoleEvent(eventImpl.release())); } return; } -- cgit v1.2.1