diff options
author | Benoit Foucher <benoit@zeroc.com> | 2018-10-23 14:57:53 +0200 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2018-10-23 14:57:53 +0200 |
commit | 242563154b3dfbb57e9bc0a81db8b887eca101da (patch) | |
tree | 72d71e72e04501da93e34f7185aa7b55ee896d36 /cpp/src/IceGrid/SessionManager.cpp | |
parent | Fixed C# build targets from documentation (diff) | |
download | ice-242563154b3dfbb57e9bc0a81db8b887eca101da.tar.bz2 ice-242563154b3dfbb57e9bc0a81db8b887eca101da.tar.xz ice-242563154b3dfbb57e9bc0a81db8b887eca101da.zip |
Fixed IceGrid bug in the algorithm to find Query objects, fixes #255
Diffstat (limited to 'cpp/src/IceGrid/SessionManager.cpp')
-rw-r--r-- | cpp/src/IceGrid/SessionManager.cpp | 42 |
1 files changed, 32 insertions, 10 deletions
diff --git a/cpp/src/IceGrid/SessionManager.cpp b/cpp/src/IceGrid/SessionManager.cpp index 2c1cac80411..ff13d25d224 100644 --- a/cpp/src/IceGrid/SessionManager.cpp +++ b/cpp/src/IceGrid/SessionManager.cpp @@ -10,6 +10,8 @@ #include <Ice/Ice.h> #include <IceGrid/SessionManager.h> +#include <set> + using namespace std; using namespace IceGrid; @@ -99,17 +101,24 @@ SessionManager::findAllQueryObjects(bool cached) } } + // + // Find all known query objects by querying all the registries we can find. + // map<Ice::Identity, QueryPrx> proxies; - vector<Ice::AsyncResultPtr> results; - size_t previousSize = 0; - do + set<QueryPrx> requested; + while(true) { + vector<Ice::AsyncResultPtr> results; for(vector<QueryPrx>::const_iterator q = queryObjects.begin(); q != queryObjects.end(); ++q) { results.push_back((*q)->begin_findAllObjectsByType(Registry::ice_staticId())); + requested.insert(*q); + } + if(results.empty()) + { + break; } - map<Ice::Identity, QueryPrx> proxies; for(vector<Ice::AsyncResultPtr>::const_iterator p = results.begin(); p != results.end(); ++p) { QueryPrx query = QueryPrx::uncheckedCast((*p)->getProxy()); @@ -123,9 +132,16 @@ SessionManager::findAllQueryObjects(bool cached) Ice::ObjectProxySeq prxs = query->end_findAllObjectsByType(*p); for(Ice::ObjectProxySeq::iterator q = prxs.begin(); q != prxs.end(); ++q) { - Ice::Identity id = (*q)->ice_getIdentity(); - id.name = "Query"; - proxies[(*q)->ice_getIdentity()] = QueryPrx::uncheckedCast((*q)->ice_identity(id)); + if(proxies.find((*q)->ice_getIdentity()) == proxies.end()) + { + // + // Add query proxy for each IceGrid registry. The proxy contains the endpoints + // of the registry since it's based on the registry interface proxy. + // + Ice::Identity id = (*q)->ice_getIdentity(); + id.name = "Query"; + proxies[(*q)->ice_getIdentity()] = QueryPrx::uncheckedCast((*q)->ice_identity(id)); + } } } catch(const Ice::Exception&) @@ -137,12 +153,18 @@ SessionManager::findAllQueryObjects(bool cached) queryObjects.clear(); for(map<Ice::Identity, QueryPrx>::const_iterator p = proxies.begin(); p != proxies.end(); ++p) { - queryObjects.push_back(p->second); + if(requested.find(p->second) == requested.end()) + { + queryObjects.push_back(p->second); + } } } - while(proxies.size() != previousSize); Lock sync(*this); - _queryObjects.swap(queryObjects); + _queryObjects.clear(); + for(map<Ice::Identity, QueryPrx>::const_iterator p = proxies.begin(); p != proxies.end(); ++p) + { + _queryObjects.push_back(p->second); + } return _queryObjects; } |