diff options
| author | Alan Conway <aconway@apache.org> | 2010-05-11 14:39:58 +0000 |
|---|---|---|
| committer | Alan Conway <aconway@apache.org> | 2010-05-11 14:39:58 +0000 |
| commit | 16da0e0c511c0c1cf4ea592640c522754065200a (patch) | |
| tree | 59fb80994db731fabe19897c95a6912e68716360 /cpp/src/qpid/broker/LinkRegistry.cpp | |
| parent | be8e1bf6b6a0d760bddbbe6642d477a95f36ab42 (diff) | |
| download | qpid-python-16da0e0c511c0c1cf4ea592640c522754065200a.tar.gz | |
Support for multiple protocols in qpid::Url.
- simplified qpid::Address to hold (protocol,host,port) triples.
- protocol plugins call Url:addProtocol to add tags to Url parser.
- use Address::protocol when establishing connections.
- ssl_test: tests using URL to connect.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@943130 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/broker/LinkRegistry.cpp')
| -rw-r--r-- | cpp/src/qpid/broker/LinkRegistry.cpp | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/cpp/src/qpid/broker/LinkRegistry.cpp b/cpp/src/qpid/broker/LinkRegistry.cpp index f32587dd68..592b64449d 100644 --- a/cpp/src/qpid/broker/LinkRegistry.cpp +++ b/cpp/src/qpid/broker/LinkRegistry.cpp @@ -95,14 +95,14 @@ void LinkRegistry::periodicMaintenance () reMappings.clear(); } -void LinkRegistry::changeAddress(const qpid::TcpAddress& oldAddress, const qpid::TcpAddress& newAddress) +void LinkRegistry::changeAddress(const qpid::Address& oldAddress, const qpid::Address& newAddress) { //done on periodic maintenance thread; hold changes in separate //map to avoid modifying the link map that is iterated over reMappings[createKey(oldAddress)] = newAddress; } -bool LinkRegistry::updateAddress(const std::string& oldKey, const qpid::TcpAddress& newAddress) +bool LinkRegistry::updateAddress(const std::string& oldKey, const qpid::Address& newAddress) { std::string newKey = createKey(newAddress); if (links.find(newKey) != links.end()) { @@ -133,9 +133,7 @@ pair<Link::shared_ptr, bool> LinkRegistry::declare(string& host, { Mutex::ScopedLock locker(lock); - stringstream keystream; - keystream << host << ":" << port; - string key = string(keystream.str()); + string key = createKey(host, port); LinkMap::iterator i = links.find(key); if (i == links.end()) @@ -168,12 +166,10 @@ pair<Bridge::shared_ptr, bool> LinkRegistry::declare(std::string& host, Mutex::ScopedLock locker(lock); QPID_LOG(debug, "Bridge declared " << host << ": " << port << " from " << src << " to " << dest << " (" << key << ")"); - stringstream keystream; - keystream << host << ":" << port; - string linkKey = string(keystream.str()); - - keystream << "!" << src << "!" << dest << "!" << key; - string bridgeKey = string(keystream.str()); + string linkKey = createKey(host, port); + stringstream keystream; + keystream << linkKey << "!" << src << "!" << dest << "!" << key; + string bridgeKey = keystream.str(); LinkMap::iterator l = links.find(linkKey); if (l == links.end()) @@ -210,9 +206,7 @@ pair<Bridge::shared_ptr, bool> LinkRegistry::declare(std::string& host, void LinkRegistry::destroy(const string& host, const uint16_t port) { Mutex::ScopedLock locker(lock); - stringstream keystream; - keystream << host << ":" << port; - string key = string(keystream.str()); + string key = createKey(host, port); LinkMap::iterator i = links.find(key); if (i != links.end()) @@ -231,16 +225,15 @@ void LinkRegistry::destroy(const std::string& host, const std::string& key) { Mutex::ScopedLock locker(lock); - stringstream keystream; - keystream << host << ":" << port; - string linkKey = string(keystream.str()); + string linkKey = createKey(host, port); + stringstream keystream; + keystream << linkKey << "!" << src << "!" << dest << "!" << key; + string bridgeKey = keystream.str(); LinkMap::iterator l = links.find(linkKey); if (l == links.end()) return; - keystream << "!" << src << "!" << dest << "!" << key; - string bridgeKey = string(keystream.str()); BridgeMap::iterator b = bridges.find(bridgeKey); if (b == bridges.end()) return; @@ -328,11 +321,18 @@ std::string LinkRegistry::getAuthIdentity(const std::string& key) } -std::string LinkRegistry::createKey(const qpid::TcpAddress& a) -{ - stringstream keystream; - keystream << a.host << ":" << a.port; - return string(keystream.str()); +std::string LinkRegistry::createKey(const qpid::Address& a) { + // TODO aconway 2010-05-11: key should also include protocol/transport to + // be unique. Requires refactor of LinkRegistry interface. + return createKey(a.host, a.port); +} + +std::string LinkRegistry::createKey(const std::string& host, uint16_t port) { + // TODO aconway 2010-05-11: key should also include protocol/transport to + // be unique. Requires refactor of LinkRegistry interface. + stringstream keystream; + keystream << host << ":" << port; + return keystream.str(); } void LinkRegistry::setPassive(bool p) |
