diff options
author | Alan Conway <aconway@apache.org> | 2012-02-17 14:15:03 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2012-02-17 14:15:03 +0000 |
commit | 78a382f594ddbcdb789d59149512699992ddd7c7 (patch) | |
tree | 2c937224badbd57bf64d46ba5d710b8192d6597d | |
parent | 2af9d3f8e5e262fd3de1a61d62150f46507177fc (diff) | |
download | qpid-python-78a382f594ddbcdb789d59149512699992ddd7c7.tar.gz |
QPID-3603: Set known hosts at connection open in Link.
Formerly were being set during periodic maintenance.
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/qpid-3603-7@1245541 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | qpid/cpp/src/qpid/broker/Link.cpp | 17 | ||||
-rw-r--r-- | qpid/cpp/src/qpid/broker/Link.h | 4 | ||||
-rw-r--r-- | qpid/cpp/src/qpid/broker/LinkRegistry.cpp | 7 | ||||
-rw-r--r-- | qpid/cpp/src/qpid/broker/LinkRegistry.h | 1 |
4 files changed, 18 insertions, 11 deletions
diff --git a/qpid/cpp/src/qpid/broker/Link.cpp b/qpid/cpp/src/qpid/broker/Link.cpp index b2c4bbdec2..b975511e59 100644 --- a/qpid/cpp/src/qpid/broker/Link.cpp +++ b/qpid/cpp/src/qpid/broker/Link.cpp @@ -64,7 +64,6 @@ Link::Link(LinkRegistry* _links, visitCount(0), currentInterval(1), closing(false), - updateUrls(false), channelCounter(1), connection(0), agent(0) @@ -147,7 +146,14 @@ void Link::established () } } -void Link::closed (int, std::string text) +void Link::opened() { + Mutex::ScopedLock mutex(lock); + assert(connection); + urls.reset(connection->getKnownHosts()); + QPID_LOG(debug, "Known hosts for peer of inter-broker link: " << urls); +} + +void Link::closed(int, std::string text) { Mutex::ScopedLock mutex(lock); QPID_LOG (info, "Inter-broker link disconnected from " << host << ":" << port << " " << text); @@ -287,7 +293,6 @@ void Link::setConnection(Connection* c) { Mutex::ScopedLock mutex(lock); connection = c; - updateUrls = true; // Process any IO tasks bridges added before setConnection. connection->requestIOProcessing (boost::bind(&Link::ioThreadProcessing, this)); } @@ -296,12 +301,6 @@ void Link::maintenanceVisit () { Mutex::ScopedLock mutex(lock); - if (connection && updateUrls) { - urls.reset(connection->getKnownHosts()); - QPID_LOG(debug, "Known hosts for peer of inter-broker link: " << urls); - updateUrls = false; - } - if (state == STATE_WAITING) { visitCount++; diff --git a/qpid/cpp/src/qpid/broker/Link.h b/qpid/cpp/src/qpid/broker/Link.h index acaa9d1cbd..a11f99e91e 100644 --- a/qpid/cpp/src/qpid/broker/Link.h +++ b/qpid/cpp/src/qpid/broker/Link.h @@ -61,7 +61,6 @@ namespace qpid { uint32_t currentInterval; bool closing; RetryList urls; - bool updateUrls; typedef std::vector<Bridge::shared_ptr> Bridges; Bridges created; // Bridges pending creation @@ -113,7 +112,8 @@ namespace qpid { void add(Bridge::shared_ptr); void cancel(Bridge::shared_ptr); - void established(); // Called when connection is created + void established(); // Called when connection is create + void opened(); // Called when connection is open (after create) void closed(int, std::string); // Called when connection goes away void setConnection(Connection*); // Set pointer to the AMQP Connection void reconnect(const Address&); //called by LinkRegistry diff --git a/qpid/cpp/src/qpid/broker/LinkRegistry.cpp b/qpid/cpp/src/qpid/broker/LinkRegistry.cpp index 1749440d7b..bb21ca01ab 100644 --- a/qpid/cpp/src/qpid/broker/LinkRegistry.cpp +++ b/qpid/cpp/src/qpid/broker/LinkRegistry.cpp @@ -53,6 +53,7 @@ struct ConnectionObserverImpl : public ConnectionObserver { LinkRegistry& links; ConnectionObserverImpl(LinkRegistry& l) : links(l) {} void connection(Connection& c) { links.notifyConnection(c.getMgmtId(), &c); } + void opened(Connection& c) { links.notifyOpened(c.getMgmtId()); } void closed(Connection& c) { links.notifyClosed(c.getMgmtId()); } void forced(Connection& c, const string& text) { links.notifyConnectionForced(c.getMgmtId(), text); } }; @@ -297,6 +298,12 @@ void LinkRegistry::notifyConnection(const std::string& key, Connection* c) } } +void LinkRegistry::notifyOpened(const std::string& key) +{ + Link::shared_ptr link = findLink(key); + if (link) link->opened(); +} + void LinkRegistry::notifyClosed(const std::string& key) { Link::shared_ptr link = findLink(key); diff --git a/qpid/cpp/src/qpid/broker/LinkRegistry.h b/qpid/cpp/src/qpid/broker/LinkRegistry.h index 7e5b39f223..e66fca7d6b 100644 --- a/qpid/cpp/src/qpid/broker/LinkRegistry.h +++ b/qpid/cpp/src/qpid/broker/LinkRegistry.h @@ -132,6 +132,7 @@ namespace broker { MessageStore* getStore() const; void notifyConnection (const std::string& key, Connection* c); + void notifyOpened (const std::string& key); void notifyClosed (const std::string& key); void notifyConnectionForced (const std::string& key, const std::string& text); std::string getAuthMechanism (const std::string& key); |