From d85193c25c22fd2b1af039f9e077b2506b05d65c Mon Sep 17 00:00:00 2001 From: Marc Laukien Date: Wed, 29 Jan 2003 18:00:12 +0000 Subject: fix --- cpp/src/Ice/ConnectionFactory.cpp | 39 +++++++++++++++++++++++++-------------- cpp/src/Ice/ConnectionFactory.h | 4 ++-- 2 files changed, 27 insertions(+), 16 deletions(-) (limited to 'cpp/src') diff --git a/cpp/src/Ice/ConnectionFactory.cpp b/cpp/src/Ice/ConnectionFactory.cpp index c4f9d03401a..319eb011ac6 100644 --- a/cpp/src/Ice/ConnectionFactory.cpp +++ b/cpp/src/Ice/ConnectionFactory.cpp @@ -139,17 +139,21 @@ IceInternal::OutgoingConnectionFactory::create(const vector& endpts // for(q = endpoints.begin(); q != endpoints.end(); ++q) { - map::const_iterator r = _connections.find(*q); - if(r != _connections.end()) + pair::const_iterator, + multimap::const_iterator> r = _connections.equal_range(*q); + + while(r.first != r.second) { // // Don't return connections for which destruction has // been initiated. // - if(!r->second->isDestroyed()) + if(!r.first->second->isDestroyed()) { - return r->second; + return r.first->second; } + + ++r.first; } } @@ -189,20 +193,24 @@ IceInternal::OutgoingConnectionFactory::create(const vector& endpts // as new connections might have been added in the meantime. // if(searchAgain) - { + { for(q = endpoints.begin(); q != endpoints.end(); ++q) { - map::const_iterator r = _connections.find(*q); - if(r != _connections.end()) + pair::const_iterator, + multimap::const_iterator> r = _connections.equal_range(*q); + + while(r.first != r.second) { // // Don't return connections for which destruction has // been initiated. // - if(!r->second->isDestroyed()) + if(!r.first->second->isDestroyed()) { - return r->second; + return r.first->second; } + + ++r.first; } } } @@ -282,7 +290,7 @@ IceInternal::OutgoingConnectionFactory::create(const vector& endpts } else { - _connections.insert(make_pair(connection->endpoint(), connection)); + _connections.insert(_connections.end(), make_pair(connection->endpoint(), connection)); if(_destroyed) { @@ -331,10 +339,13 @@ IceInternal::OutgoingConnectionFactory::setRouter(const RouterPrx& router) endpoint = endpoint->timeout(defaultsAndOverrides->overrideTimeoutValue); } - map::const_iterator q = _connections.find(endpoint); - if(q != _connections.end()) + pair::const_iterator, + multimap::const_iterator> r = _connections.equal_range(endpoint); + + while(r.first != r.second) { - q->second->setAdapter(adapter); + r.first->second->setAdapter(adapter); + ++r.first; } } } @@ -350,7 +361,7 @@ IceInternal::OutgoingConnectionFactory::removeAdapter(const ObjectAdapterPtr& ad throw CommunicatorDestroyedException(__FILE__, __LINE__); } - for(map::const_iterator p = _connections.begin(); p != _connections.end(); ++p) + for(multimap::const_iterator p = _connections.begin(); p != _connections.end(); ++p) { if(p->second->getAdapter() == adapter) { diff --git a/cpp/src/Ice/ConnectionFactory.h b/cpp/src/Ice/ConnectionFactory.h index d21af897be3..2a7d26a3a4e 100644 --- a/cpp/src/Ice/ConnectionFactory.h +++ b/cpp/src/Ice/ConnectionFactory.h @@ -60,8 +60,8 @@ private: const InstancePtr _instance; bool _destroyed; - std::map _connections; - std::set _pending; + std::multimap _connections; + std::set _pending; // Endpoints for which connection establishment is pending. }; class IncomingConnectionFactory : public EventHandler, public ::IceUtil::Monitor< ::IceUtil::Mutex> -- cgit v1.2.3